src/Entity/BFProductEdition.php line 13

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\ORM\Mapping as ORM;
  6. use Symfony\Component\Validator\Constraints as Assert;
  7. /**
  8.  * @ORM\Entity(repositoryClass="App\Repository\BFProductEditionRepository")
  9.  */
  10. class BFProductEdition
  11. {
  12.     /**
  13.      * @ORM\Id()
  14.      * @ORM\GeneratedValue()
  15.      * @ORM\Column(type="integer")
  16.      */
  17.     private $id;
  18.     /**
  19.      * @ORM\ManyToOne(targetEntity="App\Entity\BFEdition", inversedBy="bfproducteditions")
  20.      * @ORM\JoinColumn(onDelete="SET NULL")
  21.      */
  22.     private $edition;
  23.     /**
  24.      * @ORM\ManyToMany(targetEntity="App\Entity\BFTournoi", inversedBy="bfproducteditions")
  25.      * @ORM\OrderBy({"startdate" = "ASC", "enddate" = "ASC" })
  26.      */
  27.     private $tournois;
  28.     /**
  29.      * @ORM\Column(type="string", length=255)
  30.      */
  31.     private $name;
  32.     /**
  33.      * @ORM\Column(type="integer")
  34.      * @Assert\Range(
  35.      *      min = 0,
  36.      *      max = 20001,
  37.      *      notInRangeMessage = "Le prix doit être entre 0€ et 200€",)
  38.      */
  39.     private $price;
  40.     /**
  41.      * @ORM\Column(type="text")
  42.      */
  43.     private $description;
  44.     /**
  45.      * @ORM\Column(type="boolean")
  46.      */
  47.     private $isactive;
  48.     /**
  49.      * @ORM\OneToMany(targetEntity="App\Entity\BFOrderEdition", mappedBy="productedition")
  50.      */
  51.     private $bFOrderEditions;
  52.     const stripefeespercent 0.014// 1.4%
  53.     const stripefeesfix 25// 0.25€
  54.     public function __construct()
  55.     {
  56.         $this->tournois = new ArrayCollection();
  57.         $this->isactive=true;
  58.         $this->bFOrderEditions = new ArrayCollection();
  59.     }
  60.     public function getId(): ?int
  61.     {
  62.         return $this->id;
  63.     }
  64.     public function getEdition(): ?BFEdition
  65.     {
  66.         return $this->edition;
  67.     }
  68.     public function setEdition(?BFEdition $edition): self
  69.     {
  70.         $this->edition $edition;
  71.         return $this;
  72.     }
  73.     /**
  74.      * @return Collection|BFTournoi[]
  75.      */
  76.     public function getTournois(): Collection
  77.     {
  78.         return $this->tournois;
  79.     }
  80.     public function addTournois(BFTournoi $tournois): self
  81.     {
  82.         if (!$this->tournois->contains($tournois)) {
  83.             $this->tournois[] = $tournois;
  84.         }
  85.         return $this;
  86.     }
  87.     public function removeTournois(BFTournoi $tournois): self
  88.     {
  89.         if ($this->tournois->contains($tournois)) {
  90.             $this->tournois->removeElement($tournois);
  91.         }
  92.         return $this;
  93.     }
  94.     public function getName(): ?string
  95.     {
  96.         return $this->name;
  97.     }
  98.     public function setName(string $name): self
  99.     {
  100.         $this->name $name;
  101.         return $this;
  102.     }
  103.     public function getPrice(): ?int
  104.     {
  105.         return $this->price;
  106.     }
  107.     public function setPrice(int $price): self
  108.     {
  109.         $this->price $price;
  110.         return $this;
  111.     }
  112.     
  113.     public function getDisplayprice(): ?float
  114.     {
  115.         return $this->getPrice()/100;
  116.     }
  117.     public function getDescription(): ?string
  118.     {
  119.         return $this->description;
  120.     }
  121.     public function setDescription(string $description): self
  122.     {
  123.         $this->description $description;
  124.         return $this;
  125.     }
  126.     public function getIsactive(): ?bool
  127.     {
  128.         return $this->isactive;
  129.     }
  130.     public function setIsactive(bool $isactive): self
  131.     {
  132.         $this->isactive $isactive;
  133.         return $this;
  134.     }
  135.     
  136.     public function getDeleteable(): ?bool
  137.     {
  138.         foreach($this->getBFOrderEditions() as $orderedition)
  139.         {
  140.             $paymentintentedition $orderedition->getBFPaymentIntentEdition();
  141.             
  142.             if($paymentintentedition!=null && $paymentintentedition->getSuccessdate()!=null)
  143.                 return false;
  144.         }
  145.         
  146.         return true;
  147.     }
  148.     /**
  149.      * @return Collection|BFOrderEdition[]
  150.      */
  151.     public function getBFOrderEditions(): Collection
  152.     {
  153.         return $this->bFOrderEditions;
  154.     }
  155.     public function addBFOrderEdition(BFOrderEdition $bFOrderEdition): self
  156.     {
  157.         if (!$this->bFOrderEditions->contains($bFOrderEdition)) {
  158.             $this->bFOrderEditions[] = $bFOrderEdition;
  159.             $bFOrderEdition->setProductedition($this);
  160.         }
  161.         return $this;
  162.     }
  163.     public function removeBFOrderEdition(BFOrderEdition $bFOrderEdition): self
  164.     {
  165.         if ($this->bFOrderEditions->contains($bFOrderEdition)) {
  166.             $this->bFOrderEditions->removeElement($bFOrderEdition);
  167.             // set the owning side to null (unless already changed)
  168.             if ($bFOrderEdition->getProductedition() === $this) {
  169.                 $bFOrderEdition->setProductedition(null);
  170.             }
  171.         }
  172.         return $this;
  173.     }
  174.     
  175.     public function getFeebf(): ?int
  176.     {    
  177.         $festivalfee $this->getEdition()->getFestival()->getOrderfeebf();
  178.         
  179.         return (int)ceil($this->getPrice()*self::stripefeespercent)+self::stripefeesfix+$festivalfee;
  180.     }
  181.     
  182.     public function getDisplayfeebf(): ?float
  183.     {
  184.         return $this->getFeebf()/100;
  185.     }
  186. }