src/Entity/Users/Child.php line 30

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Users;
  3. use App\Entity\Educational\Course;
  4. use App\Entity\Educational\Discipline;
  5. use App\Entity\Educational\Serie;
  6. use Bo\ReportBundle\Entity\ReportVideo;
  7. use Bo\SubscriptionBundle\Entity\Offer;
  8. use Bo\SubscriptionBundle\Entity\OfferHistory;
  9. use App\Entity\Users\Parents;
  10. use Doctrine\Common\Collections\ArrayCollection;
  11. use Doctrine\ORM\Mapping as ORM;
  12. use Gedmo\Mapping\Annotation as Gedmo;
  13. use Mgilet\NotificationBundle\NotifiableInterface;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. use App\Entity\Users;
  17. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  18. /**
  19.  * @ORM\Entity(repositoryClass="App\Repository\Users\ChildRepository")
  20.  * @ORM\HasLifecycleCallbacks
  21.  * @UniqueEntity(fields={"email"},repositoryMethod="findByUniqueCriteria")
  22.  *
  23.  */
  24. class Child extends User
  25. {
  26.     private $idOption;
  27.     /**
  28.      * @var Course $course
  29.      *
  30.      * @ORM\ManyToOne(targetEntity="App\Entity\Educational\Course", inversedBy="users", cascade={"persist"})
  31.      * @ORM\JoinColumn(name="course_id", referencedColumnName="id")
  32.      * @Assert\NotNull(message="Veuillez choisir une classe")
  33.      * @Assert\Valid()
  34.      * @Groups({"api"})
  35.      */
  36.     protected $course;
  37.     /**
  38.      * @var Serie $serie
  39.      * @ORM\ManyToOne(targetEntity="App\Entity\Educational\Serie")
  40.      * @Groups({"api"})
  41.      */
  42.     protected $serie;
  43.     /**
  44.      * @var string $serie
  45.      * @ORM\Column(name="serie",length=255,nullable=true)
  46.      */
  47.     private $seriet;
  48.     /**
  49.      * @var $role
  50.      * @ORM\Column(name="roles",type="array")
  51.      */
  52.     protected $roles;
  53.     /**
  54.      * @ORM\Id
  55.      * @ORM\Column(type="integer")
  56.      * @ORM\GeneratedValue(strategy="AUTO")
  57.      */
  58.     protected $id;
  59.     /**
  60.      * @var string $academy
  61.      *
  62.      * @ORM\Column(name="academy", type="string", length=3, nullable=true)
  63.      */
  64.     private $academy;
  65.     /*
  66.      * @ORM\OneToMany(targetEntity="Bilan",mappedBy="student")
  67.      * @ORM\OrderBy({"created"="desc"})
  68.      */
  69.     private $bilans;
  70.     /*
  71.      * @ORM\OneToMany(targetEntity="SessionStudent",mappedBy="student")
  72.      *
  73.      */
  74.     private $sessions;
  75.     /*
  76.      * @ORM\OneToMany(targetEntity="OptionsStudent",mappedBy="student")
  77.      *
  78.      */
  79.     private $optionsStudent;
  80.     /*
  81.      * @ORM\OneToMany(targetEntity="AbstractUserActivity", mappedBy="user",fetch="LAZY")
  82.      * @ORM\OrderBy({"updated"="desc"})
  83.      */
  84.     private $activities;
  85.     /**
  86.      * @var string $news
  87.      *
  88.      * @ORM\Column(name="news", type="boolean", nullable=true)
  89.      */
  90.     private $news;
  91.     /**
  92.      * @var string $news
  93.      *
  94.      * @ORM\Column(name="is_bilan", type="boolean", nullable=true)
  95.      */
  96.     private $isBilan;
  97.     /**
  98.      * @var string $news
  99.      *
  100.      * @ORM\Column(name="bilan_date", type="datetime", nullable=true)
  101.      */
  102.     private $bilanDate;
  103.     /**
  104.      * @var \DateTime
  105.      * @ORM\Column(name="next_scholar_year", type="date",nullable=true)
  106.      */
  107.     private $nextScholarYear;
  108.     /**
  109.      * @var \DateTime
  110.      * @ORM\Column(type="datetime",nullable=true)
  111.      */
  112.     private $displayPopinNextScholarYear;
  113.     /**
  114.      * @var string $profExpressId
  115.      *
  116.      * @ORM\Column(name="prof_express_id", type="integer", nullable=true)
  117.      */
  118.     private $profExpressId;
  119.     /**
  120.      * @var string $phoneProfExpress
  121.      *
  122.      * @ORM\Column(type="string", nullable=true)
  123.      */
  124.     private $phoneProfExpress;
  125.     /**
  126.      * ??
  127.      */
  128.     private $updateOffer;
  129.     /***************************************** Association *************************************/
  130.     /**
  131.      * @ORM\OneToMany(targetEntity="StudentsParents", mappedBy="student")
  132.      *
  133.      */
  134.     private $parents;
  135.     /*
  136.      * @ORM\OneToMany(targetEntity="\Bo\SubscriptionBundle\Entity\Target", mappedBy="student")
  137.      * @ORM\OrderBy({"updated"="desc"})
  138.      */
  139.     private $targertOffer;
  140.     /*
  141.      * @ORM\OneToMany(targetEntity="Replay",mappedBy="student",fetch="LAZY")
  142.      * @ORM\OrderBy({"created"="desc"})
  143.      */
  144.     private $replays;
  145.     /**
  146.      * @ORM\Column(name="related_email", type="string",length=255, nullable=true)
  147.      */
  148.     private $relatedEmail;
  149.     /**
  150.      * @ORM\OneToMany(targetEntity="App\Entity\Educational\SchoolBag\ReviewProgram",mappedBy="student")
  151.      * @ORM\OrderBy({"day"="desc"})
  152.      */
  153.     private $reviewPrograms;
  154.     /**
  155.      * @ORM\ManyToOne(targetEntity="Guardiant",inversedBy="students")
  156.      */
  157.     private $guardiant;
  158.     /*
  159.      * @ORM\OneToMany(targetEntity="Note", mappedBy="student")
  160.      */
  161.     private $notes;
  162.     /**
  163.      * @ORM\ManyToOne(targetEntity="App\Entity\Educational\Academie")
  164.      */
  165.     private $academie;
  166.     /*
  167.      * @ORM\OneToMany(targetEntity="\Bo\AdministratorsBundle\Entity\Alert", mappedBy="student")
  168.      */
  169.     private $alerts;
  170.     /*
  171.      * @var ArrayCollection
  172.      * @ORM\OneToMany(targetEntity="\Bo\TrainningBundle\Entity\ListStudent",mappedBy="student")
  173.      */
  174.     private $trainings;
  175.     /**
  176.      * @var Discipline
  177.      * @ORM\ManyToOne(targetEntity="App\Entity\Educational\Discipline")
  178.      */
  179.     private $speciality;
  180.     /*
  181.      * @ORM\ManyToMany(targetEntity="Bo\MediaBundle\Entity\Video")
  182.      */
  183.     private $favoris;
  184.     /**
  185.      * @var string
  186.      */
  187.     protected $email;
  188.     /********************************************* fin ***********************************************/
  189.     public function __construct()
  190.     {
  191.         parent::__construct();
  192.         //$this->username = $this->email;
  193.         $this->plainPassword = "plainPassword";
  194.         $this->children = new ArrayCollection();
  195.         $this->homeworks = new ArrayCollection();
  196.         $this->bilans = new ArrayCollection();
  197.         $this->sessions = new ArrayCollection();
  198.         $this->optionsStudent = new ArrayCollection();
  199.         $this->activities = new ArrayCollection();
  200.         $this->offers = new ArrayCollection();
  201.         $this->targertOffer = new ArrayCollection();
  202.         $this->parents = new ArrayCollection();
  203.         $this->replays = new ArrayCollection();
  204.         $this->replaysGuardiant = new ArrayCollection();
  205.         $this->questions = new ArrayCollection();
  206.         $this->reviewPrograms = new ArrayCollection();
  207.         $this->alerts = new ArrayCollection();
  208.         $this->favoris = new ArrayCollection();
  209.         $this->trainings = new ArrayCollection();
  210.         $year = new \DateTime('10 july this year');
  211.         $now  = new \DateTime('now');
  212.         $this->nextScholarYear = $now < $year ? $year:$year->modify('+1 year') ;
  213.         $this->nextScholarYear = null;
  214.         $this->roles = [];
  215.         $this->popinShareGoodDeal = false;
  216.         $this->status = 200;
  217.         $this->origin = 'web';
  218.         $this->legalGuardianAuthorization = true;
  219.     }
  220.     /**
  221.      * @return mixed
  222.      */
  223.     public function getParents()
  224.     {
  225.         return $this->parents;
  226.     }
  227.     /**
  228.      * @param mixed $parents
  229.      */
  230.     public function setParents($parents)
  231.     {
  232.         $this->parents = $parents;
  233.     }
  234.     /**
  235.      * @return \DateTime
  236.      */
  237.     public function getNextScholarYear()
  238.     {
  239.         return $this->nextScholarYear;
  240.     }
  241.     /**
  242.      * @param \DateTime $nextScholarYear
  243.      */
  244.     public function setNextScholarYear(\DateTime $nextScholarYear)
  245.     {
  246.         $this->nextScholarYear = $nextScholarYear;
  247.     }
  248.     /**
  249.      * @return mixed
  250.      */
  251.     public function getReplays()
  252.     {
  253.         return $this->replays;
  254.     }
  255.     /**
  256.      * @param mixed $questions
  257.      */
  258.     public function setReplays($questions)
  259.     {
  260.         $this->replays = $questions;
  261.     }
  262.     /**
  263.      * @param mixed $questions
  264.      */
  265.     public function addReplays($questions)
  266.     {
  267.         $this->replays[] = $questions;
  268.     }
  269.     /**
  270.      * @return mixed
  271.      */
  272.     public function getReplaysGuardiant()
  273.     {
  274.         return $this->replaysGuardiant;
  275.     }
  276.     /**
  277.      * @param mixed $questions
  278.      */
  279.     public function setReplaysGuardiant($questions)
  280.     {
  281.         $this->replaysGuardiant = $questions;
  282.     }
  283.     /**
  284.      * @param mixed $questions
  285.      */
  286.     public function addReplaysGuardiant($questions)
  287.     {
  288.         $this->replaysGuardiant[] = $questions;
  289.     }
  290.     /**
  291.      * @param mixed $parents
  292.      */
  293.     public function addParents($parents)
  294.     {
  295.         $this->parents[] = $parents;
  296.     }
  297.     /**
  298.      * @return mixed
  299.      */
  300.     public function getHomeworks()
  301.     {
  302.         return $this->homeworks;
  303.     }
  304.     /**
  305.      * @param mixed $homeworks
  306.      */
  307.     public function addHomeworks($homeworks)
  308.     {
  309.         $this->homeworks[] = $homeworks;
  310.     }
  311.     public function serialize2()
  312.     {
  313.         return serialize(array($this->facebookId, parent::serialize()));
  314.     }
  315.     public function unserialize2($data)
  316.     {
  317.         list($this->facebookId, $parentData) = unserialize($data);
  318.         parent::unserialize($parentData);
  319.     }
  320.     /**
  321.      * Get id
  322.      *
  323.      * @return integer
  324.      */
  325.     public function getId()
  326.     {
  327.         return $this->id;
  328.     }
  329.     public function setId($id)
  330.     {
  331.         $this->id = $id;
  332.     }
  333.     /**
  334.      * Get Uid
  335.      *
  336.      * @return string
  337.      */
  338.     public function getUid()
  339.     {
  340.         return sha1($this->id);
  341.     }
  342.     /**
  343.      * Set firstname
  344.      *
  345.      * @param string $firstname
  346.      */
  347.     public function setFirstname($firstname)
  348.     {
  349.         $this->firstname = $firstname;
  350.     }
  351.     /**
  352.      * Get firstname
  353.      *
  354.      * @return string
  355.      */
  356.     public function getFirstname()
  357.     {
  358.         return $this->firstname;
  359.     }
  360.     /**
  361.      * @return string
  362.      */
  363.     public function getEmail()
  364.     {
  365.         return $this->email;
  366.     }
  367.     /**
  368.      * @return mixed
  369.      */
  370.     public function getUsername()
  371.     {
  372.         return $this->username;
  373.     }
  374.     /**
  375.      * @param mixed $username
  376.     */
  377.     public function setUsername($username)
  378.     {
  379.         $this->username = $username;
  380.     }
  381.     /**
  382.      * @param string $email
  383.      */
  384.     public function setEmail($email)
  385.     {
  386.         $this->email = $email;
  387.         //$this->username = $email;
  388.     }
  389.     /**
  390.      * Set lastname
  391.      *
  392.      * @param string $lastname
  393.      */
  394.     public function setLastname($lastname)
  395.     {
  396.         $this->lastname = $lastname;
  397.     }
  398.     /**
  399.      * Get lastname
  400.      *
  401.      * @return string
  402.      */
  403.     public function getLastname()
  404.     {
  405.         return $this->lastname;
  406.     }
  407.     public function getFullname()
  408.     {
  409.         return sprintf('%s %s', $this->getFirstname(), $this->getLastname());
  410.     }
  411.     /**
  412.      * Set phone
  413.      *
  414.      * @param string $phone
  415.      */
  416.     public function setPhone($phone)
  417.     {
  418.         $this->phone = $phone;
  419.     }
  420.     /**
  421.      * Get phone
  422.      *
  423.      * @return string
  424.      */
  425.     public function getPhone()
  426.     {
  427.         return $this->phone;
  428.     }
  429.     /**
  430.      * Set street
  431.      *
  432.      * @param string $street
  433.      */
  434.     public function setStreet($street)
  435.     {
  436.         $this->street = $street;
  437.     }
  438.     /**
  439.      * Get street
  440.      *
  441.      * @return string
  442.      */
  443.     public function getStreet()
  444.     {
  445.         return $this->street;
  446.     }
  447.     /**
  448.      * Set postalCode
  449.      *
  450.      * @param string $postalCode
  451.      */
  452.     public function setPostalCode($postalCode)
  453.     {
  454.         $this->postalCode = $postalCode;
  455.     }
  456.     /**
  457.      * Get postalCode
  458.      *
  459.      * @return string
  460.      */
  461.     public function getPostalCode()
  462.     {
  463.         return $this->postalCode;
  464.     }
  465.     /**
  466.      * Set city
  467.      *
  468.      * @param string $city
  469.      */
  470.     public function setCity($city)
  471.     {
  472.         $this->city = $city;
  473.     }
  474.     /**
  475.      * Get city
  476.      *
  477.      * @return string
  478.      */
  479.     public function getCity()
  480.     {
  481.         return $this->city;
  482.     }
  483.     /**
  484.      * Set country
  485.      *
  486.      * @param string $country
  487.      */
  488.     public function setCountry($country)
  489.     {
  490.         $this->country = $country;
  491.     }
  492.     /**
  493.      * Get country
  494.      *
  495.      * @return string
  496.      */
  497.     public function getCountry()
  498.     {
  499.         return $this->country;
  500.     }
  501.     /**
  502.      * Set promo
  503.      *
  504.      * @param boolean $promo
  505.      */
  506.     public function setPromo($promo)
  507.     {
  508.         $this->promo = $promo;
  509.     }
  510.     /**
  511.      * Get promo
  512.      *
  513.      * @return boolean
  514.      */
  515.     public function getPromo()
  516.     {
  517.         return $this->promo;
  518.     }
  519.     /**
  520.      * Set postRegistrationFormValidated
  521.      *
  522.      * @param boolean $postRegistrationFormValidated
  523.      */
  524.     public function setPostRegistrationFormValidated($postRegistrationFormValidated)
  525.     {
  526.         $this->postRegistrationFormValidated = $postRegistrationFormValidated;
  527.     }
  528.     /**
  529.      * Get postRegistrationFormValidated
  530.      *
  531.      * @return boolean
  532.      */
  533.     public function getPostRegistrationFormValidated()
  534.     {
  535.         return $this->postRegistrationFormValidated;
  536.     }
  537.     /**
  538.      * Set promoCode
  539.      *
  540.      * @param string $promoCode
  541.      */
  542.     public function setPromoCode($promoCode)
  543.     {
  544.         $this->promoCode = $promoCode;
  545.     }
  546.     /**
  547.      * Get promoCode
  548.      *
  549.      * @return string
  550.      */
  551.     public function getPromoCode()
  552.     {
  553.         return $this->promoCode;
  554.     }
  555.     /**
  556.      * Set report
  557.      *
  558.      * @param boolean $report
  559.      */
  560.     public function setReport($report)
  561.     {
  562.         $this->report = $report;
  563.     }
  564.     /**
  565.      * Get report
  566.      *
  567.      * @return boolean
  568.      */
  569.     public function getReport()
  570.     {
  571.         return $this->report;
  572.     }
  573.     /**
  574.      * Set from
  575.      *
  576.      * @param string $from
  577.      */
  578.     public function setFrom($from)
  579.     {
  580.         $this->from = $from;
  581.     }
  582.     /**
  583.      * Get from
  584.      *
  585.      * @return string
  586.      */
  587.     public function getFrom()
  588.     {
  589.         return $this->from;
  590.     }
  591.     /**
  592.      * Set course
  593.      *
  594.      * @param Course $course
  595.      */
  596.     public function setCourse($course)
  597.     {
  598.         $this->course = $course;
  599.     }
  600.     /**
  601.      * Get course
  602.      *
  603.      * @return Course
  604.      */
  605.     public function getCourse()
  606.     {
  607.         return $this->course;
  608.     }
  609.     /**
  610.      * @return Serie
  611.      */
  612.     public function getSerie()
  613.     {
  614.         return $this->serie;
  615.     }
  616.     /**
  617.      * @param string $serie
  618.      */
  619.     public function setSerie($serie)
  620.     {
  621.         $this->serie = $serie;
  622.     }
  623.     /**
  624.      * Set endSubscriptionMailSended
  625.      *
  626.      * @param integer $endSubscriptionMailSended
  627.      */
  628.     public function setEndSubscriptionMailSended($endSubscriptionMailSended)
  629.     {
  630.         $this->endSubscriptionMailSended = $endSubscriptionMailSended;
  631.     }
  632.     /**
  633.      * Get endSubscriptionMailSended
  634.      *
  635.      * @return integer
  636.      */
  637.     public function getEndSubscriptionMailSended()
  638.     {
  639.         return $this->endSubscriptionMailSended;
  640.     }
  641.     /**
  642.      * Set relatedEmail
  643.      *
  644.      * @param string $relatedEmail
  645.      */
  646.     public function setRelatedEmail($relatedEmail)
  647.     {
  648.         $this->relatedEmail = $relatedEmail;
  649.     }
  650.     /**
  651.      * Get relatedEmail
  652.      *
  653.      * @return string
  654.      */
  655.     public function getRelatedEmail()
  656.     {
  657.         return $this->relatedEmail;
  658.     }
  659.     /**
  660.      * Set academy
  661.      *
  662.      * @param string $academy
  663.      */
  664.     public function setAcademy($academy)
  665.     {
  666.         $this->academy = $academy;
  667.     }
  668.     /**
  669.      * Get academy
  670.      *
  671.      * @return string
  672.      */
  673.     public function getAcademy()
  674.     {
  675.         return $this->academy;
  676.     }
  677.     /**
  678.      * @return string
  679.      */
  680.     public function getCredentialsExpireAt()
  681.     {
  682.         return $this->credentialsExpireAt;
  683.     }
  684.     /**
  685.      * @return mixed
  686.      */
  687.     public function getRoles()
  688.     {
  689.         return $this->roles;
  690.     }
  691.     /**
  692.      * @return mixed
  693.      */
  694.     public function getBilans()
  695.     {
  696.         return $this->bilans;
  697.     }
  698.     /**
  699.      * @param mixed $bilans
  700.      */
  701.     public function addBilans($bilans)
  702.     {
  703.         $this->bilans[] = $bilans;
  704.     }
  705.     public function __toString()
  706.     {
  707.         return $this->lastname . ' ' . $this->firstname;
  708.     }
  709.     /**
  710.      * @return mixed
  711.      */
  712.     public function getSessions()
  713.     {
  714.         return $this->sessions;
  715.     }
  716.     /**
  717.      * @param mixed $sessions
  718.      */
  719.     public function addSessions($sessions)
  720.     {
  721.         $this->sessions[] = $sessions;
  722.     }
  723.     /**
  724.      * @param mixed $sessions
  725.      */
  726.     public function setSessions($sessions)
  727.     {
  728.         $this->sessions = $sessions;
  729.     }
  730.     /**
  731.      * @return mixed
  732.      */
  733.     public function getOffers()
  734.     {
  735.         return $this->offers;
  736.     }
  737.     /**
  738.      * @return mixed
  739.      */
  740.     public function setOffers($offers)
  741.     {
  742.         return $this->offers = $offers;
  743.     }
  744.     /**
  745.      * @param mixed $offers
  746.      */
  747.     public function addOffers($offers)
  748.     {
  749.         $this->offers[] = $offers;
  750.     }
  751.     /**
  752.      * @return mixed
  753.      */
  754.     public function getOptionsStudent()
  755.     {
  756.         return $this->optionsStudent;
  757.     }
  758.     /**
  759.      * @param mixed $optionsStudent
  760.      */
  761.     public function setOptionsStudent($optionsStudent)
  762.     {
  763.         $this->optionsStudent = $optionsStudent;
  764.     }
  765.     /**
  766.      * @param mixed $optionsStudent
  767.      */
  768.     public function addOptionsStudent($optionsStudent)
  769.     {
  770.         $this->optionsStudent[] = $optionsStudent;
  771.     }
  772.     /**
  773.      * @return mixed
  774.      */
  775.     public function getIdOption()
  776.     {
  777.         return $this->idOption;
  778.     }
  779.     /**
  780.      * @param mixed $idOption
  781.      */
  782.     public function setIdOption($idOption)
  783.     {
  784.         $this->idOption = $idOption;
  785.     }
  786.     /**
  787.      * @return string
  788.      */
  789.     public function getNews()
  790.     {
  791.         return $this->news;
  792.     }
  793.     /**
  794.      * @param string $news
  795.      */
  796.     public function setNews($news)
  797.     {
  798.         $this->news = $news;
  799.     }
  800.     /**
  801.      * @return string
  802.      */
  803.     public function getIsBilan()
  804.     {
  805.         return $this->isBilan;
  806.     }
  807.     /**
  808.      * @param string $isBilan
  809.      */
  810.     public function setIsBilan($isBilan)
  811.     {
  812.         $this->isBilan = $isBilan;
  813.     }
  814.     /**
  815.      * @return string
  816.      */
  817.     public function getBilanDate()
  818.     {
  819.         return $this->bilanDate;
  820.     }
  821.     /**
  822.      * @param string $bilanDate
  823.      */
  824.     public function setBilanDate($bilanDate)
  825.     {
  826.         $this->bilanDate = $bilanDate;
  827.     }
  828.     public function myOffre()
  829.     {
  830.         $offerStudentActive = $this->getOfferStudentActive();
  831.         if ($offerStudentActive === null) {
  832.             return null;
  833.         }
  834.         return $offerStudentActive->getOffer();
  835.     }
  836.     /**
  837.      * Verifie si l'utilisateur est en période d'essai
  838.      * @return bool
  839.      */
  840.     public function isTrial()
  841.     {
  842.         return false;
  843.     }
  844.     /**
  845.      * @return int
  846.      * @deprecated
  847.      */
  848.     public function nbTrial()
  849.     {
  850.         $now = new \DateTime("now");
  851.         $SubscribeDate = $this->offers[0]->getSubscripted();
  852.         $nbdays = date_diff($now, $SubscribeDate);
  853.         return $nbdays->d;
  854.     }
  855.     /**
  856.      * Return the active offer of the student
  857.      *
  858.      * @return mixed|null
  859.      */
  860.     public function getOfferStudentActive()
  861.     {
  862.         foreach($this->offers as $offer) {
  863.             if($offer->isActif() === true || $offer->isTrial()) {
  864.                 return $offer;
  865.             }
  866.         }
  867.         return null;
  868.     }
  869.     /**
  870.      * Return the active offer of the student
  871.      *
  872.      * @return mixed|null
  873.      */
  874.     public function getTrialStatus()
  875.     {
  876.         foreach($this->offers as $offer) {
  877.             if($offer->isTrial() === true  ) {
  878.                 return true;
  879.             }
  880.         }
  881.         return false;
  882.     }
  883.     /**
  884.      * Return the active offer of the student
  885.      *
  886.      * @return mixed|null
  887.      */
  888.     public function getDaysTrialStudent()
  889.     {
  890.         foreach($this->offers as $offer) {
  891.             return $offer->getDays();
  892.         }
  893.         return false;
  894.     }
  895.     /**
  896.      * @return mixed
  897.      */
  898.     public function getTargertOffer()
  899.     {
  900.         return $this->targertOffer;
  901.     }
  902.     /**
  903.      * @param mixed $targertOffer
  904.      */
  905.     public function setTargertOffer($targertOffer)
  906.     {
  907.         $this->targertOffer = $targertOffer;
  908.     }
  909.     /**
  910.      * @param mixed $targertOffer
  911.      */
  912.     public function addTargertOffer($targertOffer)
  913.     {
  914.         $this->targertOffer[] = $targertOffer;
  915.     }
  916.     public function getLabelCourse()
  917.     {
  918.         if (!is_null($this->course)) {
  919.             switch ($this->course) {
  920.                 case "Seconde":
  921.                     return "2de";
  922.                 case "Terminale":
  923.                     return "Tle";
  924.                 case "Première":
  925.                     return "1re";
  926.                 case "Troisième":
  927.                     return "3e";
  928.                 case "Tous niveaux";
  929.                     return "";
  930.                 case "Sixième";
  931.                     return "6e";
  932.             }
  933.         }
  934.         return "";
  935.     }
  936.     /**
  937.      * Determine if the student has an active susbcription by checking all his offer
  938.      * @return bool
  939.      */
  940.     public function hasOfferStudentActive()
  941.     {
  942.         return $this->getOfferStudentActive() !== null;
  943.     }
  944.     public function getPriceForChangeSubscription($priceNew)
  945.     {
  946.         return $priceNew;
  947.     }
  948.     public function customHomeworks()
  949.     {
  950.         if (empty($this->homeworks)) {
  951.             return null;
  952.         }
  953.         $custom = array();
  954.         $i = 0;
  955.         foreach ($this->homeworks as $h) {
  956.             $custom[$h->getExercise()->getDiscipline()->getTitle()][$i]["homework"] = $h;
  957.             $custom[$h->getExercise()->getDiscipline()->getTitle()][$i]["id"] = $h->getExercise()->getDiscipline()->getId();
  958.             $i++;
  959.         }
  960.         return $custom;
  961.     }
  962.     /**
  963.      * @ORM\PrePersist()
  964.      * @ORM\PreUpdate()
  965.      */
  966.     public function prepersist()
  967.     {
  968.         $this->username;
  969.     }
  970.     /**
  971.      * @return string
  972.      */
  973.     public function getSeriet()
  974.     {
  975.         return $this->seriet;
  976.     }
  977.     public function customGetSerieId()
  978.     {
  979.         return is_null($this->serie) ? $this->getSerietId() : $this->serie->getId();
  980.     }
  981.     public function getSerietId()
  982.     {
  983.         switch (strtoupper($this->seriet)) {
  984.             case 'S':
  985.                 return 1;
  986.                 break;
  987.             case 'ES':
  988.                 return 2;
  989.                 break;
  990.             case 'L':
  991.                 return 3;
  992.                 break;
  993.             default:
  994.                 return 4;
  995.                 break;
  996.         }
  997.     }
  998.     /**
  999.      * @param string $seriet
  1000.      */
  1001.     public function setSeriet($seriet)
  1002.     {
  1003.         $this->seriet = $seriet;
  1004.     }
  1005.     public function getElaticSearchParentIds()
  1006.     {
  1007.         if (empty($this->parents)) {
  1008.             return null;
  1009.         }
  1010.         $ids = array();
  1011.         foreach ($this->parents as $p) {
  1012.             $ids[] = $p->getParents()->getId();
  1013.         }
  1014.         return implode('-', $ids);
  1015.     }
  1016.     /**
  1017.      * @return mixed
  1018.      */
  1019.     public function getReviewPrograms()
  1020.     {
  1021.         return $this->reviewPrograms;
  1022.     }
  1023.     /**
  1024.      * @param mixed $reviewPrograms
  1025.      */
  1026.     public function setReviewPrograms($reviewPrograms)
  1027.     {
  1028.         $this->reviewPrograms = $reviewPrograms;
  1029.     }
  1030.     /**
  1031.      * @param mixed $reviewPrograms
  1032.      */
  1033.     public function addReviewPrograms($reviewPrograms)
  1034.     {
  1035.         $this->reviewPrograms[] = $reviewPrograms;
  1036.     }
  1037.     /**
  1038.      * @return mixed
  1039.      */
  1040.     public function getTeacher()
  1041.     {
  1042.         return $this->teacher;
  1043.     }
  1044.     /**
  1045.      * @param mixed $teacher
  1046.      */
  1047.     public function setTeacher($teacher)
  1048.     {
  1049.         $this->teacher = $teacher;
  1050.     }
  1051.     /**
  1052.      * Add notes
  1053.      *
  1054.      * @param \Bo\StudentBundle\Entity\Note $notes
  1055.      * @return Student
  1056.      */
  1057.     public function addNote( $notes)
  1058.     {
  1059.         $this->notes[] = $notes;
  1060.         return $this;
  1061.     }
  1062.     /**
  1063.      * Remove notes
  1064.      *
  1065.      * @param \Bo\StudentBundle\Entity\Note $notes
  1066.      */
  1067.     public function removeNote($notes)
  1068.     {
  1069.         $this->notes->removeElement($notes);
  1070.     }
  1071.     /**
  1072.      * Get notes
  1073.      *
  1074.      * @return \Doctrine\Common\Collections\Collection
  1075.      */
  1076.     public function getNotes()
  1077.     {
  1078.         return $this->notes;
  1079.     }
  1080.     /**
  1081.      * @return mixed
  1082.      */
  1083.     public function getAcademie()
  1084.     {
  1085.         return $this->academie;
  1086.     }
  1087.     /**
  1088.      * @param mixed $academie
  1089.      */
  1090.     public function setAcademie($academie)
  1091.     {
  1092.         $this->academie = $academie;
  1093.     }
  1094.     /**
  1095.      * @return mixed
  1096.      */
  1097.     public function getUpdateOffer()
  1098.     {
  1099.         return $this->updateOffer;
  1100.     }
  1101.     /**
  1102.      * @param mixed $updateOffer
  1103.      */
  1104.     public function setUpdateOffer($updateOffer)
  1105.     {
  1106.         $this->updateOffer = $updateOffer;
  1107.     }
  1108.     /**
  1109.      ** @param \Bo\StudentBundle\Entity\Guardiant $guardiant
  1110.      */
  1111.     public function getGuardiant()
  1112.     {
  1113.         return $this->guardiant;
  1114.     }
  1115.     /**
  1116.      ** @param \Bo\StudentBundle\Entity\Guardiant $guardiant
  1117.      * @return Guardiant
  1118.      */
  1119.     public function setGuardiant($guardiant)
  1120.     {
  1121.         $this->guardiant = $guardiant;
  1122.     }
  1123.     /**
  1124.      * @return ArrayCollection
  1125.      */
  1126.     public function getTrainings()
  1127.     {
  1128.         return $this->trainings;
  1129.     }
  1130.     /**
  1131.      * @param mixed $trainings
  1132.      */
  1133.     public function setTrainings($trainings)
  1134.     {
  1135.         $this->trainings = $trainings;
  1136.     }
  1137.     /**
  1138.      * @param mixed $trainings
  1139.      */
  1140.     public function addTrainings($trainings)
  1141.     {
  1142.         $this->trainings[] = $trainings;
  1143.     }
  1144.     public function getIdsTraining()
  1145.     {
  1146.         $return = array();
  1147.         if (!$this->trainings->isEmpty()) {
  1148.             foreach ($this->trainings as $t) {
  1149.                 $return[] = $t->getPlanning()->getTraining()->getId();
  1150.             }
  1151.         }
  1152.         return $return;
  1153.     }
  1154.     public function getTrainingByPlainning()
  1155.     {
  1156.         $return = array();
  1157.         if (!$this->trainings->isEmpty()) {
  1158.             foreach ($this->trainings as $t) {
  1159.                 $return[] = $t->getPlanning();
  1160.             }
  1161.         }
  1162.         return $return;
  1163.     }
  1164.     public function isRegisterTraining($planninId)
  1165.     {
  1166.         $return = array();
  1167.         if (!$this->trainings->isEmpty()) {
  1168.             foreach ($this->trainings as $t) {
  1169.                 if ($t->getPlanning()->getId() == $planninId) {
  1170.                     return true;
  1171.                 }
  1172.             }
  1173.         }
  1174.         return false;
  1175.     }
  1176.     public function isRegisterTrainingByTrainingId($TrainingId)
  1177.     {
  1178.         $return = array();
  1179.         if (!$this->trainings->isEmpty() && is_numeric($TrainingId)) {
  1180.             foreach ($this->trainings as $t) {
  1181.                 if ($t->getPlanning()->getTraining()->getId() == $TrainingId) {
  1182.                     return true;
  1183.                 }
  1184.             }
  1185.         }
  1186.         return false;
  1187.     }
  1188.     /**
  1189.      * @return mixed
  1190.      */
  1191.     public function getAlerts()
  1192.     {
  1193.         return $this->alerts;
  1194.     }
  1195.     /**
  1196.      * @param mixed $alerts
  1197.      */
  1198.     public function setAlerts($alerts)
  1199.     {
  1200.         $this->alerts = $alerts;
  1201.     }
  1202.     /**
  1203.      * @param mixed $alerts
  1204.      */
  1205.     public function addAlerts($alerts)
  1206.     {
  1207.         $this->alerts[] = $alerts;
  1208.     }
  1209.     /**
  1210.      * @return Discipline
  1211.      */
  1212.     public function getSpeciality()
  1213.     {
  1214.         return $this->speciality;
  1215.     }
  1216.     /**
  1217.      * @param Discipline $speciality
  1218.      */
  1219.     public function setSpeciality($speciality)
  1220.     {
  1221.         $this->speciality = $speciality;
  1222.     }
  1223.     /**
  1224.      * @return string
  1225.      */
  1226.     public function getStatusWording()
  1227.     {
  1228.         return $this->getHistoryWording();
  1229.     }
  1230.     /**
  1231.      * Get then latest Offer which is the most recent
  1232.      */
  1233.     public function getLatestOffer()
  1234.     {
  1235.         /** @var OfferStudent $offer */
  1236.         if ($offer = $this->getLatestStudentOffer()) {
  1237.             return $offer->getOffer();
  1238.         }
  1239.         return null;
  1240.     }
  1241.     /**
  1242.      * Get then latest StudentOffer which is the most recent
  1243.      */
  1244.     public function getLatestStudentOffer()
  1245.     {
  1246.         if (!$this->getOffers()->isEmpty()) {
  1247.             return $this->getOffers()->last();
  1248.         }
  1249.         return null;
  1250.     }
  1251.     /**
  1252.      * @return string
  1253.      */
  1254.     public function getDiscr()
  1255.     {
  1256.         return User::DISCR_STUDENT;
  1257.     }
  1258.     /**
  1259.      * @return mixed
  1260.      */
  1261.     public function getFavoris()
  1262.     {
  1263.         return $this->favoris;
  1264.     }
  1265.     /**
  1266.      * @param mixed $favoris
  1267.      */
  1268.     public function setFavoris($favoris)
  1269.     {
  1270.         $this->favoris = $favoris;
  1271.     }
  1272.     /**
  1273.      * @param mixed $favoris
  1274.      */
  1275.     public function addFavoris($favoris)
  1276.     {
  1277.         $this->favoris[] = $favoris;
  1278.     }
  1279.     /**
  1280.      * @param $video
  1281.      * @return bool
  1282.      */
  1283.     public function removeFavoris($video)
  1284.     {
  1285.         if ($video && $this->favoris->contains($video)) {
  1286.             $this->favoris->removeElement($video);
  1287.             return true;
  1288.         }
  1289.         return false;
  1290.     }
  1291.     public function checkisScientific()
  1292.     {
  1293.         if(($this->getCourse()->getSlug() == 'terminale' or $this->getCourse()->getSlug() == 'premiere')  and $this->getSerie()->getSlug() == 'scientifique')
  1294.         {
  1295.            return  true;
  1296.         }
  1297.         return false;
  1298.     }
  1299.     /**
  1300.      * Check if is parent
  1301.      * @param Parents $parent
  1302.      * @return bool|void
  1303.      */
  1304.     public function isHisParent(Parents $parent)
  1305.     {
  1306.         if(empty($this->parents)) {
  1307.             return false;
  1308.         }
  1309.         foreach ($this->parents as $loopParent) {
  1310.             if($loopParent->getParents()->getId() === $parent->getId()) {
  1311.                 return true;
  1312.             }
  1313.         }
  1314.         return false;
  1315.     }
  1316.     /**
  1317.      * @return string
  1318.      */
  1319.     public function getProfExpressId()
  1320.     {
  1321.         return $this->profExpressId;
  1322.     }
  1323.     /**
  1324.      * @param string $profExpressId
  1325.      */
  1326.     public function setProfExpressId(string $profExpressId): void
  1327.     {
  1328.         $this->profExpressId = $profExpressId;
  1329.     }
  1330.     /**
  1331.      * @return string
  1332.      */
  1333.     public function getPhoneProfExpress(): ?string
  1334.     {
  1335.         return $this->phoneProfExpress;
  1336.     }
  1337.     /**
  1338.      * @param string $phoneProfExpress
  1339.      */
  1340.     public function setPhoneProfExpress(?string $phoneProfExpress): void
  1341.     {
  1342.         $this->phoneProfExpress = $phoneProfExpress;
  1343.     }
  1344.     /**
  1345.      * @return \DateTime
  1346.      */
  1347.     public function getDisplayPopinNextScholarYear(): ?\DateTime
  1348.     {
  1349.         return $this->displayPopinNextScholarYear;
  1350.     }
  1351.     /**
  1352.      * @param \DateTime $displayPopinNextScholarYear
  1353.      */
  1354.     public function setDisplayPopinNextScholarYear(\DateTime $displayPopinNextScholarYear): void
  1355.     {
  1356.         $this->displayPopinNextScholarYear = $displayPopinNextScholarYear;
  1357.     }
  1358. }