<?php
namespace App\Entity\Master;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="eposm_m_order_item")
* @ORM\Entity
*/
class OrderItem
{
function getDisplay(){
if($this->feature != null) $name = $this->feature->getName();
elseif($this->service != null) $name = $this->service->getName();
return $this->quantity.'x '.$name.' dal '.$this->activationDate->format('d-m-Y').' al '.$this->expirationDate->format('d-m-Y');
}
function getDisplayTableRow($displayCost){
if($this->feature != null){
$name = $this->feature->getName();
}
elseif($this->service != null){
$name = $this->service->getName();
}
$result = '<tr><td></td><td>'.$this->quantity.' x </td><td>'.$name.'</td><td class="txt_a_c">'.$this->activationDate->format('d-m-Y').'</td><td class="txt_a_c">';
if($this->expirationDate != null )
$result.= $this->expirationDate->format('d-m-Y');
$result .='</td>';
if($displayCost){
$total = $this->quantity*$this->cost;
$result.= '<td class="txt_a_c">'.number_format($total, 2, ',','.').' €</td></tr>';
}
else
$result .= '</tr>';
return $result;
}
/**
* @ORM\Column(name="id", type="bigint")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\Column(name="quantity", type="string", length=191)
*/
protected $quantity;
/**
* @ORM\Column(name="activation_date", type="date", nullable=true)
*/
protected $activationDate;
/**
* @ORM\Column(name="expiration_date", type="date", nullable=true)
*/
protected $expirationDate;
/**
* @ORM\Column(name="cost", type="decimal", scale=2)
*/
protected $cost;
/**
* @ORM\Column(name="priority", type="integer")
*/
protected $priority;
// ManyToOne
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Master\Order", inversedBy="items")
* @ORM\JoinColumn(name="order_id", referencedColumnName="id")
*/
private $order;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Master\Feature", inversedBy="orderItems")
* @ORM\JoinColumn(name="feature_id", referencedColumnName="id")
*/
private $feature;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Master\Service", inversedBy="orderItems")
* @ORM\JoinColumn(name="service_id", referencedColumnName="id")
*/
private $service;
//
public function getId(): ?string
{
return $this->id;
}
public function getQuantity(): ?string
{
return $this->quantity;
}
public function setQuantity(string $quantity): self
{
$this->quantity = $quantity;
return $this;
}
public function getActivationDate(): ?\DateTimeInterface
{
return $this->activationDate;
}
public function setActivationDate(?\DateTimeInterface $activationDate): self
{
$this->activationDate = $activationDate;
return $this;
}
public function getExpirationDate(): ?\DateTimeInterface
{
return $this->expirationDate;
}
public function setExpirationDate(?\DateTimeInterface $expirationDate): self
{
$this->expirationDate = $expirationDate;
return $this;
}
public function getCost(): ?string
{
return $this->cost;
}
public function setCost(string $cost): self
{
$this->cost = $cost;
return $this;
}
public function getPriority(): ?int
{
return $this->priority;
}
public function setPriority(int $priority): self
{
$this->priority = $priority;
return $this;
}
public function getOrder(): ?Order
{
return $this->order;
}
public function setOrder(?Order $order): self
{
$this->order = $order;
return $this;
}
public function getFeature(): ?Feature
{
return $this->feature;
}
public function setFeature(?Feature $feature): self
{
$this->feature = $feature;
return $this;
}
public function getService(): ?Service
{
return $this->service;
}
public function setService(?Service $service): self
{
$this->service = $service;
return $this;
}
}