<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* RepairItems
*
* @ORM\Table(name="repair_items", indexes={@ORM\Index(name="repair_id", columns={"repair_id"})})
* @ORM\Entity
* @ORM\HasLifecycleCallbacks
*/
class RepairItems
{
const PAINT = 0;
const ASSEMBLY = 1;
const BODYGUARD = 2;
const MATERIAL = 3;
const OTHER = 4;
/**
* @var int
*
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @var int
*
* @ORM\Column(name="type", type="integer", nullable=false)
*/
private $type;
/**
* @var int|null
*
* @ORM\Column(name="price_qty", type="integer", nullable=true)
*/
private $priceQty;
/**
* @var int|null
*
* @ORM\Column(name="qty", type="float", nullable=true)
*/
private $qty;
/**
* @var int|null
*
* @ORM\Column(name="price_sum", type="integer", nullable=true)
*/
private $priceSum;
/**
* @var string|null
*
* @ORM\Column(name="note", type="text", length=65535, nullable=true)
*/
private $note;
/**
* @var \DateTime
*
* @ORM\Column(name="created", type="datetime", nullable=false)
*/
private $created;
/**
* @var \DateTime
*
* @ORM\Column(name="modified", type="datetime", nullable=true, options={"comment"="Módosítva"})
*/
private $modified;
/**
* @var \Repairs
*
* @ORM\ManyToOne(targetEntity="Repairs", cascade={"persist"})
* @ORM\JoinColumns({
* @ORM\JoinColumn(name="repair_id", referencedColumnName="id")
* })
*/
private $repair;
/**
* @ORM\Column(type="float", nullable=true)
*/
private $purchase_price;
public function __construct()
{
$this->created = new \DateTime();
$this->type = 0;
$this->tax = true;
}
/**
* @ORM\PrePersist
*/
public function setCreatedAtValue(): void
{
$this->created = new \DateTimeImmutable();
$this->setUpdatedAtValue();
}
/**
* @ORM\PreUpdate
*/
public function setUpdatedAtValue(): void
{
$this->modified = new \DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function getType(): ?int
{
return $this->type;
}
public function setType(int $type): self
{
$this->type = $type;
return $this;
}
public function getPriceQty(): ?int
{
return $this->priceQty;
}
public function setPriceQty(?int $priceQty): self
{
$this->priceQty = $priceQty;
return $this;
}
public function getQty(): ?float
{
return $this->qty;
}
public function setQty(?float $qty): self
{
$this->qty = $qty;
return $this;
}
public function getPriceSum(): ?int
{
return $this->priceSum;
}
public function setPriceSum(?int $priceSum): self
{
$this->priceSum = $priceSum;
return $this;
}
public function getNote(): ?string
{
return $this->note;
}
public function setNote(?string $note): self
{
$this->note = $note;
return $this;
}
public function getCreated(): ?\DateTimeInterface
{
return $this->created;
}
public function setCreated(\DateTimeInterface $created): self
{
$this->created = $created;
return $this;
}
public function getRepair(): ?Repairs
{
return $this->repair;
}
public function setRepair(?Repairs $repair): self
{
$this->repair = $repair;
return $this;
}
public function __toString()
{
return $this->note;
}
public function getQtyType()
{
switch ($this->type) {
case RepairItems::PAINT:
case RepairItems::ASSEMBLY:
case RepairItems::BODYGUARD:
return 'Work hour';
break;
case RepairItems::OTHER:
return 'Quantity';
break;
default:
return 'Quantity';
}
}
public function getQtyPriceType()
{
switch ($this->type) {
case RepairItems::PAINT:
case RepairItems::ASSEMBLY:
case RepairItems::BODYGUARD:
return 'Hourly rate';
break;
case RepairItems::OTHER:
return 'Unit price';
break;
default:
return 'Unit price';
}
}
public function getModified(): ?\DateTimeInterface
{
return $this->modified;
}
public function getPurchasePrice(): ?float
{
return $this->purchase_price;
}
public function setPurchasePrice(?float $purchase_price): self
{
$this->purchase_price = $purchase_price;
return $this;
}
public function getMaterial(): ?InventoryProduct
{
return $this->material;
}
public function setMaterial(?InventoryProduct $material): self
{
$this->material = $material;
return $this;
}
}