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