src/Entity/RepairItems.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\ORM\Mapping as ORM;
  4. /**
  5.  * RepairItems
  6.  *
  7.  * @ORM\Table(name="repair_items", indexes={@ORM\Index(name="repair_id", columns={"repair_id"})})
  8.  * @ORM\Entity
  9.  * @ORM\HasLifecycleCallbacks
  10.  */
  11. class RepairItems
  12. {
  13.     const PAINT = 0;
  14.     const ASSEMBLY = 1;
  15.     const BODYGUARD = 2;
  16.     const MATERIAL = 3;
  17.     const OTHER = 4;
  18.     /**
  19.      * @var int
  20.      *
  21.      * @ORM\Column(name="id", type="integer", nullable=false)
  22.      * @ORM\Id
  23.      * @ORM\GeneratedValue(strategy="IDENTITY")
  24.      */
  25.     private $id;
  26.     /**
  27.      * @var int
  28.      *
  29.      * @ORM\Column(name="type", type="integer", nullable=false)
  30.      */
  31.     private $type;
  32.     /**
  33.      * @var int|null
  34.      *
  35.      * @ORM\Column(name="price_qty", type="integer", nullable=true)
  36.      */
  37.     private $priceQty;
  38.     /**
  39.      * @var int|null
  40.      *
  41.      * @ORM\Column(name="qty", type="float", nullable=true)
  42.      */
  43.     private $qty;
  44.     /**
  45.      * @var int|null
  46.      *
  47.      * @ORM\Column(name="price_sum", type="integer", nullable=true)
  48.      */
  49.     private $priceSum;
  50.     /**
  51.      * @var string|null
  52.      *
  53.      * @ORM\Column(name="note", type="text", length=65535, nullable=true)
  54.      */
  55.     private $note;
  56.     /**
  57.      * @var \DateTime
  58.      *
  59.      * @ORM\Column(name="created", type="datetime", nullable=false)
  60.      */
  61.     private $created;
  62.     /**
  63.      * @var \DateTime
  64.      *
  65.      * @ORM\Column(name="modified", type="datetime", nullable=true, options={"comment"="Módosítva"})
  66.      */
  67.     private $modified;
  68.     /**
  69.      * @var \Repairs
  70.      *
  71.      * @ORM\ManyToOne(targetEntity="Repairs", cascade={"persist"})
  72.      * @ORM\JoinColumns({
  73.      *   @ORM\JoinColumn(name="repair_id", referencedColumnName="id")
  74.      * })
  75.      */
  76.     private $repair;
  77.     /**
  78.      * @ORM\Column(type="float", nullable=true)
  79.      */
  80.     private $purchase_price;
  81.     public function __construct()
  82.     {
  83.         $this->created = new \DateTime();
  84.         $this->type = 0;
  85.         $this->tax = true;
  86.     }
  87.     /**
  88.      * @ORM\PrePersist
  89.      */
  90.     public function setCreatedAtValue(): void
  91.     {
  92.         $this->created = new \DateTimeImmutable();
  93.         $this->setUpdatedAtValue();
  94.     }
  95.     /**
  96.      * @ORM\PreUpdate
  97.      */
  98.     public function setUpdatedAtValue(): void
  99.     {
  100.         $this->modified = new \DateTimeImmutable();
  101.     }
  102.     public function getId(): ?int
  103.     {
  104.         return $this->id;
  105.     }
  106.     public function getType(): ?int
  107.     {
  108.         return $this->type;
  109.     }
  110.     public function setType(int $type): self
  111.     {
  112.         $this->type = $type;
  113.         return $this;
  114.     }
  115.     public function getPriceQty(): ?int
  116.     {
  117.         return $this->priceQty;
  118.     }
  119.     public function setPriceQty(?int $priceQty): self
  120.     {
  121.         $this->priceQty = $priceQty;
  122.         return $this;
  123.     }
  124.     public function getQty(): ?float
  125.     {
  126.         return $this->qty;
  127.     }
  128.     public function setQty(?float $qty): self
  129.     {
  130.         $this->qty = $qty;
  131.         return $this;
  132.     }
  133.     public function getPriceSum(): ?int
  134.     {
  135.         return $this->priceSum;
  136.     }
  137.     public function setPriceSum(?int $priceSum): self
  138.     {
  139.         $this->priceSum = $priceSum;
  140.         return $this;
  141.     }
  142.     public function getNote(): ?string
  143.     {
  144.         return $this->note;
  145.     }
  146.     public function setNote(?string $note): self
  147.     {
  148.         $this->note = $note;
  149.         return $this;
  150.     }
  151.     public function getCreated(): ?\DateTimeInterface
  152.     {
  153.         return $this->created;
  154.     }
  155.     public function setCreated(\DateTimeInterface $created): self
  156.     {
  157.         $this->created = $created;
  158.         return $this;
  159.     }
  160.     public function getRepair(): ?Repairs
  161.     {
  162.         return $this->repair;
  163.     }
  164.     public function setRepair(?Repairs $repair): self
  165.     {
  166.         $this->repair = $repair;
  167.         return $this;
  168.     }
  169.     public function __toString()
  170.     {
  171.         return $this->note;
  172.     }
  173.     public function getQtyType()
  174.     {
  175.         switch ($this->type) {
  176.             case RepairItems::PAINT:
  177.             case RepairItems::ASSEMBLY:
  178.             case RepairItems::BODYGUARD:
  179.                 return 'Work hour';
  180.                 break;
  181.             case RepairItems::OTHER:
  182.                 return 'Quantity';
  183.                 break;
  184.             default:
  185.                 return 'Quantity';
  186.         }
  187.     }
  188.     public function getQtyPriceType()
  189.     {
  190.         switch ($this->type) {
  191.             case RepairItems::PAINT:
  192.             case RepairItems::ASSEMBLY:
  193.             case RepairItems::BODYGUARD:
  194.                 return 'Hourly rate';
  195.                 break;
  196.             case RepairItems::OTHER:
  197.                 return 'Unit price';
  198.                 break;
  199.             default:
  200.                 return 'Unit price';
  201.         }
  202.     }
  203.     public function getModified(): ?\DateTimeInterface
  204.     {
  205.         return $this->modified;
  206.     }
  207.     public function getPurchasePrice(): ?float
  208.     {
  209.         return $this->purchase_price;
  210.     }
  211.     public function setPurchasePrice(?float $purchase_price): self
  212.     {
  213.         $this->purchase_price = $purchase_price;
  214.         return $this;
  215.     }
  216.     public function getMaterial(): ?InventoryProduct
  217.     {
  218.         return $this->material;
  219.     }
  220.     public function setMaterial(?InventoryProduct $material): self
  221.     {
  222.         $this->material = $material;
  223.         return $this;
  224.     }
  225. }