src/Entity/Inscription.php line 15

  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InscriptionRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\DBAL\Types\Types;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\HttpFoundation\File\File;
  9. use Vich\UploaderBundle\Mapping\Annotation as Vich;
  10. #[ORM\Entity(repositoryClassInscriptionRepository::class)]
  11. #[Vich\Uploadable]
  12. class Inscription
  13. {
  14.     const STATUS_DRAFT 1;
  15.     const STATUS_VALID 2;
  16.     const STATUS_FAILED 3;
  17.     const STATUS_WAITING 4;
  18.     const STATUS_REFUSED 5// ce status est ajouté pour le caas de refus d'administrateur
  19.     const STATUS_PAYMENT_PENDING "Pending";
  20.     const STATUS_PAYMENT_SUCCESS "Success";
  21.     const STATUS_PAYMENT_FAILED "Failed";
  22.     const SEXE_HOMME 1;
  23.     const SEXE_FEMME 2;
  24.     // const CV_MARRIED = 1;
  25.     // const CV_SINGLE = 2;
  26.     const CV_MR 1;
  27.     const CV_MME 2;
  28.     const CV_MLLE 3;
  29.     const DEVISE_DT 'DT';
  30.     const DEVISE_EURO 'EURO';
  31.     #[ORM\Id]
  32.     #[ORM\GeneratedValue]
  33.     #[ORM\Column]
  34.     private ?int $id null;
  35.     #[ORM\Column(length255nullabletrue)]
  36.     private ?string $firstname null;
  37.     #[ORM\Column(length255nullabletrue)]
  38.     private ?string $lastname null;
  39.     #[ORM\ManyToOne(targetEntityEvenement::class, inversedBy'inscriptions'fetch"EAGER")]
  40.     #[ORM\JoinColumn(nullablefalse)]
  41.     private ?Evenement $evenement null;
  42.     #[ORM\ManyToOne(targetEntityUser::class, inversedBy'inscriptions'cascade: ["persist"], fetch"EAGER")]
  43.     #[ORM\JoinColumn(nullabletrue)]
  44.     private ?User $user null;
  45.     #[ORM\Column(typeTypes::SMALLINT)]
  46.     private ?int $status null;
  47.     #[ORM\Column(type'datetime')]
  48.     private $createdAt;
  49.     #[ORM\Column(type'datetime'nullabletrue)]
  50.     private $updatedAt;
  51.     /**
  52.      * @var Line[]|Collection|ArrayCollection
  53.      */
  54.     #[ORM\ManyToMany(targetEntityLine::class, inversedBy'inscriptions')]
  55.     #[ORM\OrderBy(["date" => "ASC""time" => "ASC"])]
  56.     private Collection $lineList;
  57.     #[ORM\Column(length255nullabletrue)]
  58.     private ?string $qrCode null;
  59.     #[ORM\Column(length255)]
  60.     private ?string $reference null;
  61.     #[ORM\Column(nullabletrueoptions: [])] // 'default' => "[]"
  62.     private ?array $allowedLines = [];
  63.     private $listOfLinesId = [];
  64.     /** @var Voucher[]|Collection */
  65.     #[ORM\OneToMany(mappedBy'inscription'targetEntityVoucher::class)]
  66.     private Collection $vouchers;
  67.     #[ORM\Column(length100nullabletrue)]
  68.     private ?string $devise;
  69.     #[ORM\Column(type'datetime'nullabletrue)]
  70.     private $datePayment;
  71.     #[ORM\Column(length255nullabletrue)]
  72.     private ?string $servicePayment null;
  73.     #[ORM\Column(name"status_payment"typeTypes::STRING)]
  74.     private ?string $statusPayment null;
  75.     #[ORM\Column(name"amount_cart"typeTypes::FLOATnullabletrue)]
  76.     private ?float $amountCart null;
  77.     #[ORM\Column(name"amount"typeTypes::FLOATnullabletrue)]
  78.     private ?float $amount null;
  79.     #[ORM\Column(name"discount"typeTypes::FLOATnullabletrue)]
  80.     private ?float $discount null;
  81.     #[ORM\Column(name"amount_payment"typeTypes::FLOATnullabletrue)]
  82.     private ?float $amountPayment null;
  83.     #[ORM\Column(name"data_payment"typeTypes::JSONnullabletrue)]
  84.     private $dataPayment = [];
  85.     #[ORM\Column(name"data_inscription"typeTypes::JSONnullabletrue)]
  86.     private $dataInscription = [];
  87.     #[ORM\Column(name"transaction"typeTypes::STRINGnullabletrue)]
  88.     private $transaction null;
  89.     // NOTE: Ce champ indique que l'inscription est validé et nécessite une vérification après une nouvelle transaction d'achat supplémentaire.
  90.     #[ORM\Column(name"need_verification"typeTypes::BOOLEANnullabletrue)]
  91.     private ?bool $needVerification null;
  92.     #[ORM\Column(name"note"typeTypes::TEXTnullabletrue)]
  93.     private $note null;
  94.     #[ORM\Column(name"note_admin"typeTypes::TEXTnullabletrue)]
  95.     private $noteAdmin null;
  96.     // NOTE: This is not a mapped field of entity metadata, just a simple property.
  97.     #[Vich\UploadableField(mapping'virements'fileNameProperty'imageName'size'imageSize')]
  98.     private ?File $imageFile null;
  99.     #[ORM\Column(nullabletrue)]
  100.     private ?string $imageName null;
  101.     #[ORM\Column(nullabletrue)]
  102.     private ?int $imageSize null;
  103.     #[ORM\Column(nullabletrue)]
  104.     private ?\DateTimeImmutable $imageUpdatedAt null;
  105.     #[ORM\Column(nullabletrue)]
  106.     private ?array $emailHistory null;
  107.     #[ORM\OneToMany(targetEntityPaymentLog::class, mappedBy'inscription')]
  108.     private Collection $paymentLogs;
  109.     #[ORM\Column(nullabletrueoptions: ['default' => 0])]
  110.     private ?int $sentMail 0;
  111.     public function __construct()
  112.     {
  113.         $this->lineList = new ArrayCollection();
  114.         $this->vouchers = new ArrayCollection();
  115.         $this->status self::STATUS_DRAFT;
  116.         $this->statusPayment self::STATUS_PAYMENT_PENDING;
  117.         $this->devise self::DEVISE_DT;
  118.         $this->dataPayment = [];
  119.         $this->paymentLogs = new ArrayCollection();
  120.     }
  121.     public function getId(): ?int
  122.     {
  123.         return $this->id;
  124.     }
  125.     public function getFirstname(): ?string
  126.     {
  127.         return $this->firstname;
  128.     }
  129.     public function setFirstname(string $firstname): self
  130.     {
  131.         $this->firstname $firstname;
  132.         return $this;
  133.     }
  134.     public function getLastname(): ?string
  135.     {
  136.         return $this->lastname;
  137.     }
  138.     public function setLastname(string $lastname): self
  139.     {
  140.         $this->lastname $lastname;
  141.         return $this;
  142.     }
  143.     public function getTitle(): ?string
  144.     {
  145.         return $this->user?->getTitle();
  146.     }
  147.     public function isTitleResidant(): bool
  148.     {
  149.         // return $this->user?->getTitle() && $this->user?->getTitle() == AppConstants::TITLE_RESIDENT;
  150.         if ($this->user) {
  151.             return $this->user->isTitleResidant();
  152.         }
  153.         return false;
  154.     }
  155.     public function getMail(): ?string
  156.     {
  157.         return $this->user $this->user->getEmail() : null;
  158.     }
  159.     public function getCivility(): ?int
  160.     {
  161.         if ($this->user && is_null($this->user->getCivility())) {
  162.             if ($this->user?->getSexe() == self::SEXE_HOMME) {
  163.                 $this->user?->setCivility(self::CV_MR);
  164.             } elseif ($this->user?->getSexe() == self::SEXE_FEMME) {
  165.                 $this->user?->setCivility(self::CV_MME);
  166.             }
  167.         }
  168.         return $this->user?->getCivility();
  169.     }
  170.     public function getSexe(): ?int
  171.     {
  172.         return $this->user?->getSexe();
  173.     }
  174.     public function getCountry(): ?string
  175.     {
  176.         return $this->user?->getCountry();
  177.     }
  178.     public function getAdresse(): ?string
  179.     {
  180.         return $this->user?->getAdresse();
  181.     }
  182.     public function getCity(): ?string
  183.     {
  184.         return $this->user?->getCity();
  185.     }
  186.     public function getPostalCode(): ?int
  187.     {
  188.         return $this->user?->getPostalCode();
  189.     }
  190.     public function getWorkplace(): ?string
  191.     {
  192.         return $this->user?->getWorkplace();
  193.     }
  194.     public function getMobile(): ?string
  195.     {
  196.         return $this->user?->getMobile();
  197.     }
  198.     public function getPhone(): ?string
  199.     {
  200.         return $this->user?->getPhone();
  201.     }
  202.     public function getSpeciality(): ?string
  203.     {
  204.         return $this->user?->getSpeciality();
  205.     }
  206.     public function getActivity(): ?string
  207.     {
  208.         return $this->user?->getActivity();
  209.     }
  210.     public function getStatus(): ?int
  211.     {
  212.         return $this->status;
  213.     }
  214.     /**
  215.      * function to inspect integer value of status and return the corresponding string status(Draft,Valid,Failed,Waiting or Refused)
  216.      * @return string|null
  217.      */
  218.     public function getStatusString(): ?string
  219.     {
  220.         $status $this->status;
  221.         if ($status == 1) {
  222.             return "Draft";
  223.         }
  224.         if ($status == 2) {
  225.             return "Valid";
  226.         }
  227.         if ($status == 3) {
  228.             return "Failed";
  229.         }
  230.         if ($status == 4) {
  231.             return "Waiting";
  232.         }
  233.         return "Refused";
  234.     }
  235.     public function setStatus(int $status): self
  236.     {
  237.         $this->status $status;
  238.         return $this;
  239.     }
  240.     public function getEvenement(): ?Evenement
  241.     {
  242.         return $this->evenement;
  243.     }
  244.     public function setEvenement(?Evenement $evenement): self
  245.     {
  246.         $this->evenement $evenement;
  247.         return $this;
  248.     }
  249.     public function getCreatedAt(): ?\DateTimeInterface
  250.     {
  251.         return $this->createdAt;
  252.     }
  253.     public function setCreatedAt(\DateTimeInterface $createdAt): self
  254.     {
  255.         $this->createdAt $createdAt;
  256.         return $this;
  257.     }
  258.     public function getUpdatedAt(): ?\DateTimeInterface
  259.     {
  260.         return $this->updatedAt;
  261.     }
  262.     public function setUpdatedAt(?\DateTimeInterface $updatedAt): self
  263.     {
  264.         $this->updatedAt $updatedAt;
  265.         return $this;
  266.     }
  267.     /**
  268.      * @return Collection<int, Line>
  269.      */
  270.     public function getLineList(): Collection
  271.     {
  272.         return $this->lineList;
  273.     }
  274.     public function addLineList(Line $lineList): self
  275.     {
  276.         if (!$this->lineList->contains($lineList)) {
  277.             $this->lineList->add($lineList);
  278.         }
  279.         return $this;
  280.     }
  281.     public function removeLineList(Line $lineList): self
  282.     {
  283.         $this->lineList->removeElement($lineList);
  284.         return $this;
  285.     }
  286.     public function getQrCode(): ?string
  287.     {
  288.         return $this->qrCode;
  289.     }
  290.     public function setQrCode(?string $qrCode): self
  291.     {
  292.         $this->qrCode $qrCode;
  293.         return $this;
  294.     }
  295.     public function getQRCodeData(): string
  296.     {
  297.         $data = [
  298.             $this->reference,
  299.             $this->evenement $this->evenement->getId() : 0,
  300.             $this->id $this->id 0,
  301.             $this->firstname,
  302.             $this->lastname,
  303.             $this->user?->getEmail() ?: "",
  304.             "event_parent_id=" . ($this->evenement && $this->evenement->getParent() && $this->evenement->getParent()->getId() ? $this->evenement->getParent()->getId() : ""),
  305.             // $this->adresse,
  306.             // $this->city,
  307.             // $this->postalCode,
  308.         ];
  309.         return implode("#"$data);
  310.     }
  311.     public function getReference(): ?string
  312.     {
  313.         return $this->reference;
  314.     }
  315.     public function setReference(string $reference): self
  316.     {
  317.         $this->reference $reference;
  318.         return $this;
  319.     }
  320.     public function getListOfLinesId()
  321.     {
  322.         $data = [];
  323.         /** @var Line $line */
  324.         foreach ($this->lineList as $line) {
  325.             $data[] = $line->getId();
  326.         }
  327.         $this->listOfLinesId $data;
  328.         return $data;
  329.     }
  330.     /**
  331.      * @return Collection<int, Voucher>
  332.      */
  333.     public function getVouchers(): Collection
  334.     {
  335.         return $this->vouchers;
  336.     }
  337.     public function addVoucher(Voucher $voucher): self
  338.     {
  339.         if (!$this->vouchers->contains($voucher)) {
  340.             $this->vouchers->add($voucher);
  341.             $voucher->setInscription($this);
  342.         }
  343.         return $this;
  344.     }
  345.     public function removeVoucher(Voucher $voucher): self
  346.     {
  347.         if ($this->vouchers->removeElement($voucher)) {
  348.             // set the owning side to null (unless already changed)
  349.             if ($voucher->getInscription() === $this) {
  350.                 $voucher->setInscription(null);
  351.             }
  352.         }
  353.         return $this;
  354.     }
  355.     /**
  356.      * Get the value of devise
  357.      */
  358.     public function getDevise(): ?string
  359.     {
  360.         return $this->devise;
  361.     }
  362.     /**
  363.      * Set the value of devise
  364.      *
  365.      * @return  self
  366.      */
  367.     public function setDevise(?string $devise): self
  368.     {
  369.         $this->devise $devise;
  370.         return $this;
  371.     }
  372.     public function getDatePayment(): ?\DateTimeInterface
  373.     {
  374.         return $this->datePayment;
  375.     }
  376.     public function setDatePayment(?\DateTimeInterface $datePayment): self
  377.     {
  378.         $this->datePayment $datePayment;
  379.         return $this;
  380.     }
  381.     public function getServicePayment(): ?string
  382.     {
  383.         return $this->servicePayment;
  384.     }
  385.     public function setServicePayment(string $servicePayment): self
  386.     {
  387.         $this->servicePayment $servicePayment;
  388.         return $this;
  389.     }
  390.     /**
  391.      * Get the value of statusPayment
  392.      */
  393.     public function getStatusPayment()
  394.     {
  395.         return $this->statusPayment;
  396.     }
  397.     /**
  398.      * Set the value of statusPayment
  399.      *
  400.      * @return  self
  401.      */
  402.     public function setStatusPayment($statusPayment): self
  403.     {
  404.         $this->statusPayment $statusPayment;
  405.         return $this;
  406.     }
  407.     public function getAmountCart()
  408.     {
  409.         return $this->amountCart;
  410.     }
  411.     public function setAmountCart($amountCart): self
  412.     {
  413.         $this->amountCart $amountCart;
  414.         return $this;
  415.     }
  416.     public function calculPayment(): float
  417.     {
  418.         $amount 0;
  419.         if ($this->lineList) {
  420.             foreach ($this->lineList as $line) {
  421.                 if ($line) {
  422.                     if ($this->devise == self::DEVISE_DT) {
  423.                         $amount += $this->isTitleResidant() ? $line->getPriceResidant() : $line->getPrice();
  424.                     } else if ($this->devise == self::DEVISE_EURO) {
  425.                         $amount += $this->isTitleResidant() ? $line->getPriceResidantEuro() : $line->getPriceEuro();
  426.                     }
  427.                 }
  428.             }
  429.         }
  430.         $this->amount $amount;
  431.         # voucher
  432.         $discount 0;
  433.         if ($this->vouchers) {
  434.             foreach ($this->vouchers as $voucher) {
  435.                 if ($voucher) {
  436.                     # TYPE_UNLIMITED / TYPE_LIMITED
  437.                     if ($voucher->getPrice() && $voucher->getType() == Voucher::TYPE_LIMITED) {
  438.                         $discount += $voucher->getPrice();
  439.                         $amount -= $voucher->getPrice();
  440.                     } elseif ($voucher->getType() == Voucher::TYPE_UNLIMITED) {
  441.                         $discount += $amount;
  442.                         $amount -= $amount;
  443.                     }
  444.                 }
  445.             }
  446.         }
  447.         $this->discount $discount;
  448.         $this->amountPayment $amount;
  449.         return $amount;
  450.     }
  451.     public function updatePlacesReserved()
  452.     {
  453.         if ($this->status == self::STATUS_VALID) {
  454.             foreach ($this->lineList as $line) {
  455.                 if ($line->getNumberOfPlaces() && $line->getNumberOfPlacesReserved() < $line->getNumberOfPlaces()) {
  456.                     $place $line->getNumberOfPlacesReserved();
  457.                     if (is_null($place)) {
  458.                         $place 0;
  459.                     }
  460.                     $line->setNumberOfPlacesReserved($place 1);
  461.                 }
  462.             }
  463.         }
  464.     }
  465.     public function updatePlacesUnReserved()
  466.     {
  467.         if (in_array($this->status, [self::STATUS_WAITINGself::STATUS_DRAFT])) {
  468.             foreach ($this->lineList as $line) {
  469.                 if ($line->getNumberOfPlaces() && $line->getNumberOfPlacesReserved() <= $line->getNumberOfPlaces()) {
  470.                     $place $line->getNumberOfPlacesReserved();
  471.                     if (is_null($place)) {
  472.                         $place 0;
  473.                     }
  474.                     if ($place 0) {
  475.                         $line->setNumberOfPlacesReserved($place 1);
  476.                     }
  477.                 }
  478.             }
  479.         }
  480.     }
  481.     public function updateVouchersUsed()
  482.     {
  483.         if ($this->status == self::STATUS_VALID) {
  484.             if ($this->getVouchers()) {
  485.                 // foreach ($inscription->getVouchers()->getValues() as $value) {
  486.                 foreach ($this->getVouchers() as $voucher) {
  487.                     $voucher->setUsed(true);
  488.                 }
  489.             }
  490.         }
  491.     }
  492.     public function getAmount(): ?float
  493.     {
  494.         return $this->amount;
  495.     }
  496.     public function setAmount(?float $amount): self
  497.     {
  498.         $this->amount $amount;
  499.         return $this;
  500.     }
  501.     public function getAmountPayment(): ?float
  502.     {
  503.         return $this->amountPayment;
  504.     }
  505.     public function setAmountPayment(?float $amountPayment): self
  506.     {
  507.         $this->amountPayment $amountPayment;
  508.         return $this;
  509.     }
  510.     /**
  511.      * Get the value of user
  512.      */
  513.     public function getUser(): ?User
  514.     {
  515.         return $this->user;
  516.     }
  517.     /**
  518.      * Set the value of user
  519.      */
  520.     public function setUser(?User $user): self
  521.     {
  522.         $this->user $user;
  523.         if ($user) {
  524.             if ($user->getCountry() && $user->getCountry() == "TN") {
  525.                 $this->setDevise(Inscription::DEVISE_DT);
  526.             } else {
  527.                 $this->setDevise(Inscription::DEVISE_EURO);
  528.             }
  529.             if (!$this->getFirstname() && $user->getFirstname()) {
  530.                 $this->setFirstname($user->getFirstname());
  531.             }
  532.             if (!$this->getLastname() && $user->getLastname()) {
  533.                 $this->setLastname($user->getLastname());
  534.             }
  535.         }
  536.         return $this;
  537.     }
  538.     /**
  539.      * Get the value of dataPayment
  540.      *
  541.      * @return array|null
  542.      */
  543.     public function getDataPayment()
  544.     {
  545.         if (is_null($this->dataPayment)) {
  546.             $this->dataPayment = [];
  547.         }
  548.         return $this->dataPayment;
  549.     }
  550.     /**
  551.      * Set the value of dataPayment
  552.      *
  553.      * @param array|null $dataPayment
  554.      */
  555.     public function setDataPayment($dataPaymentbool $merge false): self
  556.     {
  557.         if (is_null($this->dataPayment)) {
  558.             $this->dataPayment = [];
  559.         }
  560.         if (key_exists('action'$this->dataPayment) || key_exists('reference'$this->dataPayment) || key_exists('service'$this->dataPayment)) {
  561.             $this->dataPayment = [=> $this->dataPayment];
  562.         }
  563.         if (!is_array($this->dataPayment)) {
  564.             $this->dataPayment = [=> $this->dataPayment];
  565.         }
  566.         // if ($merge) {
  567.         // $this->dataPayment = array_merge($this->dataPayment, $dataPayment);
  568.         // } else {
  569.         $this->dataPayment[] = $dataPayment;
  570.         // }
  571.         return $this;
  572.     }
  573.     /**
  574.      * Get the value of discount
  575.      *
  576.      * @return float|null
  577.      */
  578.     public function getDiscount()
  579.     {
  580.         return $this->discount;
  581.     }
  582.     /**
  583.      * Set the value of discount
  584.      *
  585.      * @param float|null $discount
  586.      *
  587.      * @return  self
  588.      */
  589.     public function setDiscount($discount): self
  590.     {
  591.         $this->discount $discount;
  592.         return $this;
  593.     }
  594.     public function hasNeedVerification(): ?bool
  595.     {
  596.         return $this->getNeedVerification();
  597.     }
  598.     public function getNeedVerification(): ?bool
  599.     {
  600.         return $this->needVerification;
  601.     }
  602.     public function setNeedVerification(?bool $needVerification null): self
  603.     {
  604.         $this->needVerification $needVerification;
  605.         return $this;
  606.     }
  607.     /**
  608.      * Get the value of note
  609.      */
  610.     public function getNote()
  611.     {
  612.         return $this->note;
  613.     }
  614.     /**
  615.      * Set the value of note
  616.      *
  617.      * @return  self
  618.      */
  619.     public function setNote($note): self
  620.     {
  621.         $this->note $note;
  622.         return $this;
  623.     }
  624.     /**
  625.      * Get the value of noteAdmin
  626.      */
  627.     public function getnoteAdmin()
  628.     {
  629.         return $this->noteAdmin;
  630.     }
  631.     /**
  632.      * Set the value of noteAdmin
  633.      *
  634.      * @return  self
  635.      */
  636.     public function setnoteAdmin($noteAdmin): self
  637.     {
  638.         $this->noteAdmin $noteAdmin;
  639.         return $this;
  640.     }
  641.     /**
  642.      * If manually uploading a file (i.e. not using Symfony Form) ensure an instance
  643.      * of 'UploadedFile' is injected into this setter to trigger the update. If this
  644.      * bundle's configuration parameter 'inject_on_load' is set to 'true' this setter
  645.      * must be able to accept an instance of 'File' as the bundle will inject one here
  646.      * during Doctrine hydration.
  647.      *
  648.      * @param File|\Symfony\Component\HttpFoundation\File\UploadedFile|null $imageFile
  649.      */
  650.     public function setImageFile(?File $imageFile null): void
  651.     {
  652.         $this->imageFile $imageFile;
  653.         if (null !== $imageFile) {
  654.             // It is required that at least one field changes if you are using doctrine
  655.             // otherwise the event listeners won't be called and the file is lost
  656.             $this->imageUpdatedAt = new \DateTimeImmutable();
  657.         }
  658.     }
  659.     public function getImageFile(): ?File
  660.     {
  661.         return $this->imageFile;
  662.     }
  663.     public function setImageName(?string $imageName): void
  664.     {
  665.         $this->imageName $imageName;
  666.     }
  667.     public function getImageName(): ?string
  668.     {
  669.         return $this->imageName;
  670.     }
  671.     public function setImageSize(?int $imageSize): void
  672.     {
  673.         $this->imageSize $imageSize;
  674.     }
  675.     public function getImageSize(): ?int
  676.     {
  677.         return $this->imageSize;
  678.     }
  679.     public function getImageUpdatedAt(): ?\DateTimeImmutable
  680.     {
  681.         return $this->imageUpdatedAt;
  682.     }
  683.     public function getEmailHistory(): ?array
  684.     {
  685.         if (is_null($this->emailHistory)) {
  686.             $this->emailHistory = [];
  687.         }
  688.         return $this->emailHistory;
  689.     }
  690.     public function setEmailHistory(?array $emailHistory = []): static
  691.     {
  692.         if (is_null($emailHistory)) {
  693.             $emailHistory = [];
  694.         }
  695.         $this->emailHistory $emailHistory;
  696.         return $this;
  697.     }
  698.     /**
  699.      * @param int $id line_id
  700.      * @return int
  701.      * returns the index of the email_history array where are the email details  for a specific line_id
  702.      */
  703.     public function getEmailHistoryWithLineId(int $id)
  704.     {
  705.         $j 0;
  706.         $emailHistory $this->getEmailHistory();
  707.         foreach ($emailHistory as $email) {
  708.             if ($email['line_id'] == $id) {
  709.                 break;
  710.             }
  711.             $j++;
  712.         }
  713.         if ($j == count($emailHistory)) {
  714.             return -1;
  715.         } else {
  716.             return $j;
  717.         }
  718.     }
  719.     /**
  720.      * @return Collection<int, PaymentLog>
  721.      */
  722.     public function getPaymentLogs(): Collection
  723.     {
  724.         return $this->paymentLogs;
  725.     }
  726.     public function addPaymentLog(PaymentLog $paymentLog): static
  727.     {
  728.         if (!$this->paymentLogs->contains($paymentLog)) {
  729.             $this->paymentLogs->add($paymentLog);
  730.             $paymentLog->setInscription($this);
  731.         }
  732.         return $this;
  733.     }
  734.     public function removePaymentLog(PaymentLog $paymentLog): static
  735.     {
  736.         if ($this->paymentLogs->removeElement($paymentLog)) {
  737.             // set the owning side to null (unless already changed)
  738.             if ($paymentLog->getInscription() === $this) {
  739.                 $paymentLog->setInscription(null);
  740.             }
  741.         }
  742.         return $this;
  743.     }
  744.     /**
  745.      * Get the value of transaction
  746.      */
  747.     public function getTransaction(): ?string
  748.     {
  749.         return $this->transaction;
  750.     }
  751.     /**
  752.      * Set the value of transaction
  753.      *
  754.      * @return  self
  755.      */
  756.     public function setTransaction(?string $transaction)
  757.     {
  758.         $this->transaction $transaction;
  759.         return $this;
  760.     }
  761.     /**
  762.      * Get the value of dataInscription
  763.      */
  764.     public function getDataInscription()
  765.     {
  766.         if (is_null($this->dataInscription)) {
  767.             $this->dataInscription = [];
  768.         }
  769.         return array_unique($this->dataInscription);
  770.     }
  771.     /**
  772.      * Set the value of dataInscription
  773.      */
  774.     public function setDataInscription($dataInscription): self
  775.     {
  776.         if (is_null($dataInscription)) {
  777.             $dataInscription = [];
  778.         }
  779.         $this->dataInscription array_unique(array_filter($dataInscription));
  780.         return $this;
  781.     }
  782.     public function addDataInscription($item): self
  783.     {
  784.         if (is_null($this->dataInscription)) {
  785.             $this->dataInscription = [];
  786.         }
  787.         if (is_array($this->dataInscription)) {
  788.             $this->dataInscription[] = $item;
  789.             $this->dataInscription array_unique(array_filter($this->dataInscription));
  790.         }
  791.         return $this;
  792.     }
  793.     public function getSentMail()
  794.     {
  795.         if (is_null($this->sentMail)) {
  796.             $this->sentMail 0;
  797.         }
  798.         return $this->sentMail;
  799.     }
  800.     public function setSentMail($sentMail): self
  801.     {
  802.         $this->sentMail $sentMail;
  803.         return $this;
  804.     }
  805.     public function incrementSentMail()
  806.     {
  807.         $this->getSentMail();
  808.         return $this->sentMail++;
  809.     }
  810.     public function ableToSend(): bool
  811.     {
  812.         $this->getSentMail();
  813.         return $this->sentMail 2;
  814.     }
  815.     public function getAllowedLines()
  816.     {
  817.         return $this->allowedLines;
  818.     }
  819.     public function setAllowedLines($allowedLines)
  820.     {
  821.         $this->allowedLines array_unique(array_filter($allowedLines));
  822.         return $this;
  823.     }
  824.     public function addAllowedLines($line_id null)
  825.     {
  826.         if ($line_id) {
  827.             $this->allowedLines[] = $line_id;
  828.             $this->allowedLines array_unique(array_filter($this->allowedLines));
  829.         }
  830.         return $this;
  831.     }
  832. }