src/Entity/CRM/OrderProduct.php line 14

  1. <?php
  2. namespace App\Entity\CRM;
  3. use App\Repository\OrderProductRepository;
  4. use DateTime;
  5. use DateTimeInterface;
  6. use Doctrine\Common\Collections\ArrayCollection;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\DBAL\Types\Types;
  9. use Doctrine\ORM\Mapping as ORM;
  10. #[ORM\Entity(repositoryClassOrderProductRepository::class)]
  11. class OrderProduct
  12. {
  13.     #[ORM\Id]
  14.     #[ORM\GeneratedValue]
  15.     #[ORM\Column]
  16.     private ?int $id null;
  17.     #[ORM\Column]
  18.     private ?float $priceSubtotal null;
  19.     private float $priceTotal;
  20.     private float $productSumSubtotal;
  21.     private float $productSumTotal;
  22.     #[ORM\Column]
  23.     private ?int $quantity null;
  24.     #[ORM\Column(typeTypes::DATETIME_MUTABLE)]
  25.     private DateTimeInterface $addedDate;
  26.     #[ORM\Column(typeTypes::DATETIME_MUTABLE,nullabletrue)]
  27.     private ?DateTimeInterface $modifiedDate null;
  28.     #[ORM\ManyToOne(inversedBy'orderProduct')]
  29.     #[ORM\JoinColumn(nullablefalse)]
  30.     private ?Order $orderId null;
  31.     #[ORM\ManyToOne(inversedBy'orderProducts'cascade: ['persist'])]
  32.     #[ORM\JoinColumn(nullablefalse)]
  33.     private ?Product $product null;
  34.     #[ORM\OneToMany(mappedBy'orderProduct'targetEntityImplementerOrderProduct::class, orphanRemovaltrue)]
  35.     private Collection $implementerOrderProducts;
  36.     #[ORM\OneToMany(mappedBy'orderProduct'targetEntityBhpOrderProduct::class, orphanRemovaltrue)]
  37.     private Collection $BhpOrderProducts;
  38.     #[ORM\Column]
  39.     private bool $autoMailBlock false;
  40.     #[ORM\Column]
  41.     private bool $sendedMail false;
  42.     #[ORM\Column(typeTypes::DATETIME_MUTABLEnullabletrue)]
  43.     private ?\DateTimeInterface $sendedDate null;
  44.     #[ORM\Column(nullabletrue)]
  45.     private ?int $administrationFee null;
  46.     public function __construct()
  47.     {
  48.         $this->addedDate = new DateTime();
  49.         $this->implementerOrderProducts = new ArrayCollection();
  50.         $this->BhpOrderProducts = new ArrayCollection();
  51.         $this->autoMailBlock false;
  52.         $this->sendedMail false;
  53.     }
  54.     public function __toString(): string
  55.     {
  56.         return $this->product->getName();
  57.     }
  58.     public function getId(): ?int
  59.     {
  60.         return $this->id;
  61.     }
  62.     public function getPriceSubtotal(): ?float
  63.     {
  64.         return $this->priceSubtotal;
  65.     }
  66.     public function setPriceSubtotal(float $priceSubtotal): self
  67.     {
  68.         $this->priceSubtotal $priceSubtotal;
  69.         return $this;
  70.     }
  71.     public function getPriceTotal(): ?float
  72.     {
  73.         return $this->priceSubtotal + ($this->priceSubtotal * ($this->product->getTax() / 100));
  74.     }
  75.     public function getQuantity(): ?int
  76.     {
  77.         return $this->quantity;
  78.     }
  79.     public function setQuantity(int $quantity): self
  80.     {
  81.         $this->quantity $quantity;
  82.         return $this;
  83.     }
  84.     public function getAddedDate(): DateTimeInterface
  85.     {
  86.         return $this->addedDate;
  87.     }
  88.     public function getModifiedDate(): ?DateTimeInterface
  89.     {
  90.         return $this->modifiedDate;
  91.     }
  92.     public function setModifiedDate(): self
  93.     {
  94.         $this->modifiedDate = new DateTime();
  95.         return $this;
  96.     }
  97.     public function getOrderId(): ?Order
  98.     {
  99.         return $this->orderId;
  100.     }
  101.     public function setOrderId(?Order $orderId): self
  102.     {
  103.         $this->orderId $orderId;
  104.         return $this;
  105.     }
  106.     public function getProduct(): ?Product
  107.     {
  108.         return $this->product;
  109.     }
  110.     public function setProduct(?Product $product): self
  111.     {
  112.         $this->product $product;
  113.         return $this;
  114.     }
  115.     /**
  116.      * @return Collection<int, ImplementerOrderProduct>
  117.      */
  118.     public function getImplementerOrderProducts(): Collection
  119.     {
  120.         return $this->implementerOrderProducts;
  121.     }
  122.     public function addImplementerOrderProduct(ImplementerOrderProduct $implementerOrderProduct): static
  123.     {
  124.         if (!$this->implementerOrderProducts->contains($implementerOrderProduct)) {
  125.             $this->implementerOrderProducts->add($implementerOrderProduct);
  126.             $implementerOrderProduct->setOrderProduct($this);
  127.         }
  128.         return $this;
  129.     }
  130.     public function removeImplementerOrderProduct(ImplementerOrderProduct $implementerOrderProduct): static
  131.     {
  132.         if ($this->implementerOrderProducts->removeElement($implementerOrderProduct)) {
  133.             // set the owning side to null (unless already changed)
  134.             if ($implementerOrderProduct->getOrderProduct() === $this) {
  135.                 $implementerOrderProduct->setOrderProduct(null);
  136.             }
  137.         }
  138.         return $this;
  139.     }
  140.     /**
  141.      * @return Collection<int, BhpOrderProduct>
  142.      */
  143.     public function getBhpOrderProducts(): Collection
  144.     {
  145.         return $this->BhpOrderProducts;
  146.     }
  147.     public function addBhpOrderProduct(BhpOrderProduct $BhpOrderProduct): static
  148.     {
  149.         if (!$this->BhpOrderProducts->contains($BhpOrderProduct)) {
  150.             $this->BhpOrderProducts->add($BhpOrderProduct);
  151.             $BhpOrderProduct->setOrderProduct($this);
  152.         }
  153.       
  154.         return $this;
  155.     }
  156.     public function isAutoMailBlock(): ?bool
  157.     {
  158.         return $this->autoMailBlock;
  159.     }
  160.     public function setAutoMailBlock(bool $autoMailBlock): static
  161.     {
  162.         $this->autoMailBlock $autoMailBlock;
  163.         return $this;
  164.     }
  165.     public function removeBhpOrderProduct(BhpOrderProduct $BhpOrderProduct): static
  166.     {
  167.         if ($this->BhpOrderProducts->removeElement($BhpOrderProduct)) {
  168.             // set the owning side to null (unless already changed)
  169.             if ($BhpOrderProduct->getOrderProduct() === $this) {
  170.                 $BhpOrderProduct->setOrderProduct(null);
  171.             }
  172.         }
  173.         return $this;
  174.     }
  175.     public function isSendedMail(): ?bool
  176.     {
  177.         return $this->sendedMail;
  178.     }
  179.     public function setSendedMail(bool $sendedMail): static
  180.     {
  181.         $this->sendedMail $sendedMail;
  182.         return $this;
  183.     }
  184.     public function getSendedDate(): ?\DateTimeInterface
  185.     {
  186.         return $this->sendedDate;
  187.     }
  188.     public function setSendedDate(?\DateTimeInterface $sendedDate): static
  189.     {
  190.         $this->sendedDate $sendedDate;
  191.         return $this;
  192.     }
  193.     public function getAdministrationFee(): ?int
  194.     {
  195.         return $this->administrationFee;
  196.     }
  197.     public function setAdministrationFee(int $administrationFee): static
  198.     {
  199.         $this->administrationFee $administrationFee;
  200.         return $this;
  201.     }
  202.     public function getOrderProductAgreementToken(): string
  203.     {
  204.         $token = match ($this->product->getAgreement()->getType()) {
  205.             'rodo' => $this->orderId->getToken(),
  206.             'aml' => $this->orderId->getTokenAml(),
  207.             'amlrodo' => $this->orderId->getTokenAmlrodo(),
  208.             'bdo' => $this->orderId->getTokenBdo(),
  209.             'bhpstacjonarna' => $this->orderId->getTokenBhpStationary(),
  210.             'biurarachunkowe' => $this->orderId->getTokenOffice(),
  211.             'iod' => $this->orderId->getTokenIod(),
  212.             'rodobhp' => $this->orderId->getTokenBhpRodo(),
  213.             'licencyjnewebaml' => $this->orderId->getTokenLicencyjnaWebAml(),
  214.             'licencyjnewebamlpartnerska' => $this->orderId->getTokenLicencyjnaWebAmlPartnerska(),
  215.             'licencyjnewebamlnieruchomosci' => $this->orderId->getTokenLicencyjnaWebAmlNieruchomosci(),
  216.             default => '',
  217.         };
  218.         if($token){
  219.             return $token;
  220.         }else{
  221.             return '';
  222.         }
  223.     }
  224. }