src/Entity/Quotes.php line 17

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 Doctrine\Common\Collections\Criteria;
  7. use function Symfony\Component\Translation\t;
  8. /**
  9.  * Quotes
  10.  *
  11.  * @ORM\Table(name="quotes", indexes={@ORM\Index(name="car_id", columns={"car_id"})})
  12.  * @ORM\Entity
  13.  */
  14. class Quotes
  15. {
  16.     /**
  17.      * @var int
  18.      *
  19.      * @ORM\Column(name="id", type="integer", nullable=false)
  20.      * @ORM\Id
  21.      * @ORM\GeneratedValue(strategy="IDENTITY")
  22.      */
  23.     private $id;
  24.     /**
  25.      * @var int|null
  26.      *
  27.      * @ORM\Column(name="price_sum", type="integer", nullable=true)
  28.      */
  29.     private $priceSum;
  30.     /**
  31.      * @var int|null
  32.      *
  33.      * @ORM\Column(name="price_sum_br", type="integer", nullable=true)
  34.      */
  35.     private $priceSumBr;
  36.     /**
  37.      * @var string|null
  38.      *
  39.      * @ORM\Column(name="note", type="text", length=65535, nullable=true)
  40.      */
  41.     private $note;
  42.     /**
  43.      * @var \DateTime
  44.      *
  45.      * @ORM\Column(name="created", type="datetime", nullable=false)
  46.      */
  47.     private $created;
  48.     /**
  49.      * @var int|null
  50.      *
  51.      * @ORM\Column(name="price_bodyguard", type="integer", nullable=true)
  52.      */
  53.     private $priceBodyguard;
  54.     /**
  55.      * @var int|null
  56.      *
  57.      * @ORM\Column(name="price_paint", type="integer", nullable=true)
  58.      */
  59.     private $pricePaint;
  60.     /**
  61.      * @var int|null
  62.      *
  63.      * @ORM\Column(name="price_assembly", type="integer", nullable=true)
  64.      */
  65.     private $priceAssembly;
  66.     /**
  67.      * @var int
  68.      *
  69.      * @ORM\Column(name="tax", type="string", nullable=false)
  70.      */
  71.     private $tax;
  72.     /**
  73.      * @var \Cars
  74.      *
  75.      * @ORM\ManyToOne(targetEntity="Cars")
  76.      * @ORM\JoinColumns({
  77.      *   @ORM\JoinColumn(name="car_id", referencedColumnName="id")
  78.      * })
  79.      */
  80.     private $car;
  81.     /**
  82.      * @ORM\OneToMany(targetEntity=QuoteItems::class, mappedBy="quote", cascade={"persist"},orphanRemoval=true)
  83.      */
  84.     public $quoteItems;
  85.     /**
  86.      * @ORM\OneToMany(targetEntity=Attachment::class, mappedBy="quote", cascade={"persist"},orphanRemoval=true)
  87.      */
  88.     public $attachments;
  89.     /**
  90.      * @var \DateTime
  91.      *
  92.      * @ORM\Column(name="modified", type="datetime", nullable=true, options={"comment"="Módosítva"})
  93.      */
  94.     private $modified;
  95.     public function __construct()
  96.     {
  97.         $this->created = new \DateTime();
  98.         $this->quoteItems = new ArrayCollection();
  99.         $this->attachments = new ArrayCollection();
  100.     }
  101.     public function getId(): ?int
  102.     {
  103.         return $this->id;
  104.     }
  105.     public function getTax(): ?string
  106.     {
  107.         return $this->tax;
  108.     }
  109.     public function setTax(?string $tax): self
  110.     {
  111.         $this->tax = $tax;
  112.         return $this;
  113.     }
  114.     public function getPriceSum(): ?int
  115.     {
  116.         return $this->priceSum;
  117.     }
  118.     public function setPriceSum(?int $priceSum): self
  119.     {
  120.         $this->priceSum = $priceSum;
  121.         return $this;
  122.     }
  123.     public function getPriceSumBr(): ?int
  124.     {
  125.         return $this->priceSumBr;
  126.     }
  127.     public function setPriceSumBr(?int $priceSumBr): self
  128.     {
  129.         $this->priceSumBr = $priceSumBr;
  130.         return $this;
  131.     }
  132.     public function getNote(): ?string
  133.     {
  134.         return $this->note;
  135.     }
  136.     public function setNote(?string $note): self
  137.     {
  138.         $this->note = $note;
  139.         return $this;
  140.     }
  141.     public function getCreated(): ?\DateTimeInterface
  142.     {
  143.         return $this->created;
  144.     }
  145.     public function setCreated(\DateTimeInterface $created): self
  146.     {
  147.         $this->created = $created;
  148.         return $this;
  149.     }
  150.     public function getCar(): ?Cars
  151.     {
  152.         return $this->car;
  153.     }
  154.     public function setCar(?Cars $car): self
  155.     {
  156.         $this->car = $car;
  157.         return $this;
  158.     }
  159.     /**
  160.      * @return Collection|QuoteItems[]
  161.      */
  162.     public function getQuoteItems(): Collection
  163.     {
  164.         return $this->quoteItems;
  165.     }
  166.     // public function addQuoteItem(QuoteItems $quoteItem): self
  167.     // {
  168.     //     if (!$this->quoteItems->contains($quoteItem)) {
  169.     //         $quoteItem->setQuote($this);
  170.     //         $this->quoteItems[] = $quoteItem;
  171.     //     }
  172.     //     return $this;
  173.     // }
  174.     // public function removeQuoteItem(QuoteItems $quoteItem): self
  175.     // {
  176.     //     if ($this->quoteItems->removeElement($quoteItem)) {
  177.     //         // set the owning side to null (unless already changed)
  178.     //         if ($quoteItem->getQuote() === $this) {
  179.     //             $quoteItem->setQuote(null);
  180.     //         }
  181.     //     }
  182.     //     return $this;
  183.     // }
  184.     /**
  185.      * @return Collection|QuoteItems[]
  186.      */
  187.     public function getQuotePaintItems(): Collection
  188.     {
  189.         $criteria = Criteria::create();
  190.         $criteria->where(Criteria::expr()->eq('type', QuoteItems::PAINT));
  191.         return $this->quoteItems->matching($criteria);
  192.     }
  193.     public function addQuotePaintItem(QuoteItems $quoteItem): self
  194.     {
  195.         if (!$this->quoteItems->contains($quoteItem)) {
  196.             $quoteItem->setType(QuoteItems::PAINT);
  197.             if ($this->getPricePaint() !== null) {
  198.                 $quoteItem->setPriceQty($this->pricePaint);
  199.             }
  200.             $quoteItem->setQuote($this);
  201.             $this->quoteItems[] = $quoteItem;
  202.         }
  203.         return $this;
  204.     }
  205.     public function removeQuotePaintItem(QuoteItems $quoteItem): self
  206.     {
  207.         if ($this->quoteItems->removeElement($quoteItem)) {
  208.             // set the owning side to null (unless already changed)
  209.             // if ($quoteItem->getQuote() === $this) {
  210.             //     $quoteItem->setQuote(null);
  211.             // }
  212.         }
  213.         return $this;
  214.     }
  215.     /**
  216.      * @return Collection|QuoteItems[]
  217.      */
  218.     public function getQuoteAssemblyItems(): Collection
  219.     {
  220.         $criteria = Criteria::create();
  221.         $criteria->where(Criteria::expr()->eq('type', QuoteItems::ASSEMBLY));
  222.         return $this->quoteItems->matching($criteria);
  223.     }
  224.     public function addQuoteAssemblyItem(QuoteItems $quoteItem): self
  225.     {
  226.         if (!$this->quoteItems->contains($quoteItem)) {
  227.             $quoteItem->setType(QuoteItems::ASSEMBLY);
  228.             if ($this->getPriceAssembly() !== null) {
  229.                 $quoteItem->setPriceQty($this->priceAssembly);
  230.             }
  231.             $quoteItem->setQuote($this);
  232.             $this->quoteItems[] = $quoteItem;
  233.         }
  234.         return $this;
  235.     }
  236.     public function removeQuoteAssemblyItem(QuoteItems $quoteItem): self
  237.     {
  238.         if ($this->quoteItems->removeElement($quoteItem)) {
  239.             // set the owning side to null (unless already changed)
  240.             if ($quoteItem->getQuote() === $this) {
  241.                 $quoteItem->setQuote(null);
  242.             }
  243.         }
  244.         return $this;
  245.     }
  246.     /**
  247.      * @return Collection|QuoteItems[]
  248.      */
  249.     public function getQuoteBodyguardItems(): Collection
  250.     {
  251.         $criteria = Criteria::create();
  252.         $criteria->where(Criteria::expr()->eq('type', QuoteItems::BODYGUARD));
  253.         return $this->quoteItems->matching($criteria);
  254.     }
  255.     public function addQuoteBodyguardItem(QuoteItems $quoteItem): self
  256.     {
  257.         if (!$this->quoteItems->contains($quoteItem)) {
  258.             $quoteItem->setType(QuoteItems::BODYGUARD);
  259.             if ($this->getPriceBodyguard() !== null) {
  260.                 $quoteItem->setPriceQty($this->priceBodyguard);
  261.             }
  262.             $quoteItem->setQuote($this);
  263.             $this->quoteItems[] = $quoteItem;
  264.         }
  265.         return $this;
  266.     }
  267.     public function removeQuoteBodyguardItem(QuoteItems $quoteItem): self
  268.     {
  269.         if ($this->quoteItems->removeElement($quoteItem)) {
  270.             // set the owning side to null (unless already changed)
  271.             if ($quoteItem->getQuote() === $this) {
  272.                 $quoteItem->setQuote(null);
  273.             }
  274.         }
  275.         return $this;
  276.     }
  277.     /**
  278.      * @return Collection|QuoteItems[]
  279.      */
  280.     public function getQuoteOtherItems(): Collection
  281.     {
  282.         $criteria = Criteria::create();
  283.         $criteria->where(Criteria::expr()->eq('type', QuoteItems::OTHER));
  284.         return $this->quoteItems->matching($criteria);
  285.     }
  286.     public function addQuoteOtherItem(QuoteItems $quoteItem): self
  287.     {
  288.         if (!$this->quoteItems->contains($quoteItem)) {
  289.             $quoteItem->setType(QuoteItems::OTHER);
  290.             $quoteItem->setQuote($this);
  291.             $this->quoteItems[] = $quoteItem;
  292.         }
  293.         return $this;
  294.     }
  295.     public function removeQuoteOtherItem(QuoteItems $quoteItem): self
  296.     {
  297.         if ($this->quoteItems->removeElement($quoteItem)) {
  298.             // set the owning side to null (unless already changed)
  299.             if ($quoteItem->getQuote() === $this) {
  300.                 $quoteItem->setQuote(null);
  301.             }
  302.         }
  303.         return $this;
  304.     }
  305.     /**
  306.      * @return Collection|Attachment[]
  307.      */
  308.     public function getAttachments(): Collection
  309.     {
  310.         return $this->attachments;
  311.     }
  312.     public function addAttachment(Attachment $photo): self
  313.     {
  314.         if (!$this->attachments->contains($photo)) {
  315.             $photo->setQuote($this);
  316.             $this->attachments[] = $photo;
  317.         }
  318.         return $this;
  319.     }
  320.     public function removeAttachment(Attachment $photo): self
  321.     {
  322.         if ($this->attachments->removeElement($photo)) {
  323.             // set the owning side to null (unless already changed)
  324.             if ($photo->getQuote() === $this) {
  325.                 $photo->setQuote(null);
  326.             }
  327.         }
  328.         return $this;
  329.     }
  330.     public function getPriceBodyguard(): ?int
  331.     {
  332.         return $this->priceBodyguard;
  333.     }
  334.     public function setPriceBodyguard(?int $priceBodyguard): self
  335.     {
  336.         $this->priceBodyguard = $priceBodyguard;
  337.         return $this;
  338.     }
  339.     public function getPricePaint(): ?int
  340.     {
  341.         return $this->pricePaint;
  342.     }
  343.     public function setPricePaint(?int $pricePaint): self
  344.     {
  345.         $this->pricePaint = $pricePaint;
  346.         return $this;
  347.     }
  348.     public function getPriceAssembly(): ?int
  349.     {
  350.         return $this->priceAssembly;
  351.     }
  352.     public function setPriceAssembly(?int $priceAssembly): self
  353.     {
  354.         $this->priceAssembly = $priceAssembly;
  355.         return $this;
  356.     }
  357.     public function __toString()
  358.     {
  359.         // TODO: Fix translation
  360.         if ($this->getCar()) {
  361.             return t('Quotation') . ' - ' . $this->getCar()->getPlateNumber() . " - " . $this->getCreated()->format('Ymd');
  362.         } else {
  363.             return t('Quotation') . ' - ' . $this->getCreated()->format('Ymd');
  364.         }
  365.     }
  366.     public function rowCss()
  367.     {
  368.         return "";
  369.     }
  370.     public function getModified(): ?\DateTimeInterface
  371.     {
  372.         return $this->modified;
  373.     }
  374. }