src/Entity/Preinscription.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. /**
  10.  * @ORM\Entity
  11.  * @ORM\Table(name="mmpp_preinscription")
  12.  * @ORM\Entity(repositoryClass="App\Repository\PreinscriptionRepository");
  13.  * @ORM\HasLifecycleCallbacks
  14.  */
  15. class Preinscription
  16. {
  17.     CONST PREINSCRIPTIONS_STATES = [
  18.         => 'Créés',
  19.         => 'File d\'attente',
  20.         => 'Stages',
  21.         => 'Payés & annulés',
  22.         => 'Internat',
  23.     ];
  24.     /**
  25.      * @ORM\Id
  26.      * @ORM\Column(type="integer")
  27.      * @ORM\GeneratedValue(strategy="AUTO")
  28.      */
  29.     protected $id;
  30.     /**
  31.      * @ORM\Column(type="string")
  32.      * @var string
  33.      */
  34.     protected $firstname;
  35.     /**
  36.      * @ORM\Column(type="string")
  37.      * @var string
  38.      */
  39.     protected $lastname;
  40.     /**
  41.      * @ORM\Column(name="generated_key", type="string", length=255)
  42.      * @var String
  43.      */
  44.     protected $generatedKey;
  45.     /**
  46.      * @ORM\Column(type="boolean")
  47.      * @var boolean
  48.      */
  49.     protected $validated;
  50.     /**
  51.      * @ORM\Column(type="boolean", nullable=true)
  52.      * @var boolean
  53.      */
  54.     protected $deleted;
  55.     /**
  56.      * @ORM\Column(name="email_send", type="boolean")
  57.      * @var boolean
  58.      */
  59.     protected $emailSend;
  60.     /**
  61.      * @ORM\Column(type="datetime", name="created_on")
  62.      * @var \DateTime
  63.      */
  64.     protected $createdOn;
  65.     /**
  66.      * @ORM\Column(type="datetime", name="updated_on")
  67.      * @var \DateTime
  68.      */
  69.     protected $updatedOn;
  70.     /**
  71.      * @ORM\Column(type="string", name="payment_type")
  72.      * @var string
  73.      */
  74.     private $paymentType;
  75.     /**
  76.      * @ORM\ManyToOne(targetEntity="Center", inversedBy="preinscriptions")
  77.      * @ORM\JoinColumn(name="center_id", referencedColumnName="id")
  78.      */
  79.     protected $center;
  80.     /**
  81.      * @ORM\ManyToOne(targetEntity="Formulaire", inversedBy="preinscriptions")
  82.      * @ORM\JoinColumn(name="formulaire_id", referencedColumnName="id")
  83.      */
  84.     protected $formulaire;
  85.     /**
  86.      * @ORM\OneToMany(targetEntity="PreinscriptionData", mappedBy="preinscription")
  87.      */
  88.     protected $datas;
  89.     /**
  90.      * @ORM\OneToMany(targetEntity="InscriptionFileLog", mappedBy="preinscription")
  91.      * @var InscriptionFileLog[]
  92.      */
  93.     protected $logs;
  94.     /**
  95.      * @ORM\OneToMany(targetEntity="Transaction", mappedBy="preinscription")
  96.      * @ORM\OrderBy({"transactionDatetime": "desc"})
  97.      */
  98.     protected $transactions;
  99.     /**
  100.      * @ORM\ManyToOne(targetEntity="Periode", inversedBy="preinscriptions")
  101.      * @ORM\JoinColumn(name="periode_id", referencedColumnName="id")
  102.      */
  103.     protected $periode;
  104.     /**
  105.      * @ORM\Column(name="email_reminder_first", type="datetime", nullable=true)
  106.      * @var \DateTime
  107.      */
  108.     protected $emailReminderFirst;
  109.     /**
  110.      * @ORM\Column(name="email_reminder_second", type="datetime", nullable=true)
  111.      * @var \DateTime
  112.      */
  113.     protected $emailReminderSecond;
  114.     /**
  115.      * @ORM\Column(name="email_ar_send", type="datetime", nullable=true)
  116.      * @var \DateTime
  117.      */
  118.     protected $emailArSend;
  119.     /**
  120.      * @ORM\Column(name="email_pr_link_send", type="datetime", nullable=true)
  121.      * @var \DateTime
  122.      */
  123.     protected $emailPrLinkSend;
  124.     /**
  125.      * @ORM\Column(name="email_pr_ar_send", type="datetime", nullable=true)
  126.      * @var \DateTime
  127.      */
  128.     protected $emailPrArSend;
  129.     /**
  130.      * @ORM\Column(name="memo", type="string", nullable=true, length=255)
  131.      * @var String
  132.      */
  133.     protected $memo;
  134.     /**
  135.      * @ORM\Column(name="state", type="integer", length=1)
  136.      * @var integer
  137.      */
  138.     protected $state 0;
  139.     /**
  140.      * @ORM\Column(name="cancelled_at", type="datetime", nullable=true)
  141.      * @var \DateTime
  142.      */
  143.     protected $cancelledAt;
  144.     public function __construct()
  145.     {
  146.         $this->datas = new ArrayCollection();
  147.         $this->logs = new ArrayCollection();
  148.         $this->transactions = new ArrayCollection();
  149.     }
  150.     /**
  151.      * Get name for display
  152.      */
  153.     public function getName()
  154.     {
  155.         return $this->lastname.' '.$this->firstname;
  156.     }
  157.     /**
  158.      * Get email to send inscription
  159.      */
  160.     public function getEmail()
  161.     {
  162.         $email null;
  163.         foreach ($this->datas as $data) {
  164.             if ($data->getKey() == 'Adresse e-mail') {
  165.                 $email $data->getValue();
  166.             }
  167.             if ($data->getKey() == "Adresse e-mail de l'étudiant") {
  168.                 $email $data->getValue();
  169.             }
  170.         }
  171.         return $email;
  172.     }
  173.     public function getEmailParent()
  174.     {
  175.         $email null;
  176.         foreach ($this->datas as $data) {
  177.             if ($data->getKey() == 'Adresse e-mail des parents') {
  178.                 $email $data->getValue();
  179.             }
  180.         }
  181.         return $email;
  182.     }
  183.     public function getLieu()
  184.     {
  185.         $lieu null;
  186.         foreach ($this->datas as $data) {
  187.             if ($data->getKey() == 'Lieu') {
  188.                 $lieu $data->getValue();
  189.             }
  190.         }
  191.         return $lieu;
  192.     }
  193.     public function hasSuccessfulTransaction()
  194.     {
  195.         /** @var Transaction $transaction */
  196.         foreach ($this->getTransactions() as $transaction) {
  197.             if ($transaction->getResponseCode() === '00' || $transaction->getResponseCode() === '00000000') {
  198.                 return true;
  199.             }
  200.         }
  201.         return false;
  202.     }
  203.     public function hasAValidPayment(): bool
  204.     {
  205.         if ($this->getPaymentType() === 'manual' || $this->getPaymentType() === 'check') {
  206.             return true;
  207.         }
  208.         /** @var Transaction $transaction */
  209.         foreach ($this->getTransactions() as $transaction) {
  210.             if ($transaction->getResponseCode() === '00' || $transaction->getResponseCode() === '00000000') {
  211.                 return true;
  212.             }
  213.         }
  214.         return false;
  215.     }
  216.     public function hasPreRentree()
  217.     {
  218.         /** @var Transaction $transaction */
  219.         foreach ($this->getDatas() as $data) {
  220.             if(str_contains($data->getKey(), 'Stage pré-rentrée')){
  221.                 if(strtoupper($data->getValue()) == 'OUI'){
  222.                     return true;
  223.                 }
  224.             }
  225.         }
  226.         return false;
  227.     }
  228.     public function getSuccessfulTransaction()
  229.     {
  230.         foreach ($this->getTransactions() as $transaction) {
  231.             if ($transaction->getResponseCode() === '00' || $transaction->getResponseCode() === '00000000') {
  232.                 return $transaction;
  233.             }
  234.         }
  235.         return null;
  236.     }
  237.     public function isValidated(): ?bool
  238.     {
  239.         return $this->validated;
  240.     }
  241.     public function isDeleted(): ?bool
  242.     {
  243.         return $this->deleted;
  244.     }
  245.     public function isEmailSend(): ?bool
  246.     {
  247.         return $this->emailSend;
  248.     }
  249.     public function getId(): ?int
  250.     {
  251.         return $this->id;
  252.     }
  253.     public function getFirstname(): ?string
  254.     {
  255.         return $this->firstname;
  256.     }
  257.     public function setFirstname(string $firstname): self
  258.     {
  259.         $this->firstname $firstname;
  260.         return $this;
  261.     }
  262.     public function getLastname(): ?string
  263.     {
  264.         return $this->lastname;
  265.     }
  266.     public function setLastname(string $lastname): self
  267.     {
  268.         $this->lastname $lastname;
  269.         return $this;
  270.     }
  271.     public function getGeneratedKey(): ?string
  272.     {
  273.         return $this->generatedKey;
  274.     }
  275.     public function setGeneratedKey(string $generatedKey): self
  276.     {
  277.         $this->generatedKey $generatedKey;
  278.         return $this;
  279.     }
  280.     public function setValidated(bool $validated): self
  281.     {
  282.         $this->validated $validated;
  283.         return $this;
  284.     }
  285.     public function setDeleted(?bool $deleted): self
  286.     {
  287.         $this->deleted $deleted;
  288.         return $this;
  289.     }
  290.     public function setEmailSend(bool $emailSend): self
  291.     {
  292.         $this->emailSend $emailSend;
  293.         return $this;
  294.     }
  295.     public function getCreatedOn(): ?\DateTimeInterface
  296.     {
  297.         return $this->createdOn;
  298.     }
  299.     public function setCreatedOn(\DateTimeInterface $createdOn): self
  300.     {
  301.         $this->createdOn $createdOn;
  302.         return $this;
  303.     }
  304.     public function getUpdatedOn(): ?\DateTimeInterface
  305.     {
  306.         return $this->updatedOn;
  307.     }
  308.     public function setUpdatedOn(\DateTimeInterface $updatedOn): self
  309.     {
  310.         $this->updatedOn $updatedOn;
  311.         return $this;
  312.     }
  313.     public function getPaymentType(): ?string
  314.     {
  315.         return $this->paymentType;
  316.     }
  317.     public function setPaymentType(string $paymentType): self
  318.     {
  319.         $this->paymentType $paymentType;
  320.         return $this;
  321.     }
  322.     public function getEmailReminderFirst(): ?\DateTimeInterface
  323.     {
  324.         return $this->emailReminderFirst;
  325.     }
  326.     public function setEmailReminderFirst(?\DateTimeInterface $emailReminderFirst): self
  327.     {
  328.         $this->emailReminderFirst $emailReminderFirst;
  329.         return $this;
  330.     }
  331.     public function getEmailReminderSecond(): ?\DateTimeInterface
  332.     {
  333.         return $this->emailReminderSecond;
  334.     }
  335.     public function setEmailReminderSecond(?\DateTimeInterface $emailReminderSecond): self
  336.     {
  337.         $this->emailReminderSecond $emailReminderSecond;
  338.         return $this;
  339.     }
  340.     public function getEmailArSend(): ?\DateTimeInterface
  341.     {
  342.         return $this->emailArSend;
  343.     }
  344.     public function setEmailArSend(?\DateTimeInterface $emailArSend): self
  345.     {
  346.         $this->emailArSend $emailArSend;
  347.         return $this;
  348.     }
  349.     public function getMemo(): ?string
  350.     {
  351.         return $this->memo;
  352.     }
  353.     public function setMemo(?string $memo): self
  354.     {
  355.         $this->memo $memo;
  356.         return $this;
  357.     }
  358.     public function getState(): ?int
  359.     {
  360.         return $this->state;
  361.     }
  362.     public function setState(int $state): self
  363.     {
  364.         $this->state $state;
  365.         return $this;
  366.     }
  367.     public function getCenter(): ?Center
  368.     {
  369.         return $this->center;
  370.     }
  371.     public function setCenter(?Center $center): self
  372.     {
  373.         $this->center $center;
  374.         return $this;
  375.     }
  376.     public function getFormulaire(): ?Formulaire
  377.     {
  378.         return $this->formulaire;
  379.     }
  380.     public function setFormulaire(?Formulaire $formulaire): self
  381.     {
  382.         $this->formulaire $formulaire;
  383.         return $this;
  384.     }
  385.     /**
  386.      * @return Collection<int, PreinscriptionData>
  387.      */
  388.     public function getDatas(): Collection
  389.     {
  390.         return $this->datas;
  391.     }
  392.     public function addData(PreinscriptionData $data): self
  393.     {
  394.         if (!$this->datas->contains($data)) {
  395.             $this->datas->add($data);
  396.             $data->setPreinscription($this);
  397.         }
  398.         return $this;
  399.     }
  400.     public function removeData(PreinscriptionData $data): self
  401.     {
  402.         if ($this->datas->removeElement($data)) {
  403.             // set the owning side to null (unless already changed)
  404.             if ($data->getPreinscription() === $this) {
  405.                 $data->setPreinscription(null);
  406.             }
  407.         }
  408.         return $this;
  409.     }
  410.     /**
  411.      * @return Collection<int, InscriptionFileLog>
  412.      */
  413.     public function getLogs(): Collection
  414.     {
  415.         return $this->logs;
  416.     }
  417.     public function addLog(InscriptionFileLog $log): self
  418.     {
  419.         if (!$this->logs->contains($log)) {
  420.             $this->logs->add($log);
  421.             $log->setPreinscription($this);
  422.         }
  423.         return $this;
  424.     }
  425.     public function removeLog(InscriptionFileLog $log): self
  426.     {
  427.         if ($this->logs->removeElement($log)) {
  428.             // set the owning side to null (unless already changed)
  429.             if ($log->getPreinscription() === $this) {
  430.                 $log->setPreinscription(null);
  431.             }
  432.         }
  433.         return $this;
  434.     }
  435.     /**
  436.      * @return Collection<int, Transaction>
  437.      */
  438.     public function getTransactions(): Collection
  439.     {
  440.         return $this->transactions;
  441.     }
  442.     public function addTransaction(Transaction $transaction): self
  443.     {
  444.         if (!$this->transactions->contains($transaction)) {
  445.             $this->transactions->add($transaction);
  446.             $transaction->setPreinscription($this);
  447.         }
  448.         return $this;
  449.     }
  450.     public function removeTransaction(Transaction $transaction): self
  451.     {
  452.         if ($this->transactions->removeElement($transaction)) {
  453.             // set the owning side to null (unless already changed)
  454.             if ($transaction->getPreinscription() === $this) {
  455.                 $transaction->setPreinscription(null);
  456.             }
  457.         }
  458.         return $this;
  459.     }
  460.     public function getPeriode(): ?Periode
  461.     {
  462.         return $this->periode;
  463.     }
  464.     public function setPeriode(?Periode $periode): self
  465.     {
  466.         $this->periode $periode;
  467.         return $this;
  468.     }
  469.     /**
  470.      * @return \DateTime
  471.      */
  472.     public function getEmailPrLinkSend(): ?\DateTime
  473.     {
  474.         return $this->emailPrLinkSend;
  475.     }
  476.     /**
  477.      * @param \DateTime $emailPrLinkSend
  478.      */
  479.     public function setEmailPrLinkSend(\DateTime $emailPrLinkSend): void
  480.     {
  481.         $this->emailPrLinkSend $emailPrLinkSend;
  482.     }
  483.     /**
  484.      * @return \DateTime
  485.      */
  486.     public function getEmailPrArSend(): ?\DateTime
  487.     {
  488.         return $this->emailPrArSend;
  489.     }
  490.     /**
  491.      * @param \DateTime $emailPrArSend
  492.      */
  493.     public function setEmailPrArSend(\DateTime $emailPrArSend): void
  494.     {
  495.         $this->emailPrArSend $emailPrArSend;
  496.     }
  497.     public function getCancelledAt(): ?\DateTime
  498.     {
  499.         return $this->cancelledAt;
  500.     }
  501.     public function setCancelledAt(\DateTime $cancelledAt): void
  502.     {
  503.         $this->cancelledAt $cancelledAt;
  504.     }
  505.     public function getFullName(): string
  506.     {
  507.         return $this->firstname ' ' $this->lastname;
  508.     }
  509. }