src/Entity/Master/OrderItem.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Master;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\DBAL\Types\Types;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Table(name="eposm_m_order_item")
  9.  * @ORM\Entity
  10.  */
  11. class OrderItem
  12. {    
  13.     function getDisplay(){
  14.         if($this->feature != null$name $this->feature->getName();
  15.         elseif($this->service != null$name $this->service->getName();
  16.         return $this->quantity.'x '.$name.' dal '.$this->activationDate->format('d-m-Y').' al '.$this->expirationDate->format('d-m-Y');
  17.     }
  18.     
  19.     function getDisplayTableRow($displayCost){
  20.         if($this->feature != null){
  21.             $name $this->feature->getName();
  22.         }
  23.         elseif($this->service != null){
  24.             $name $this->service->getName();
  25.         }
  26.         $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">';
  27.         if($this->expirationDate != null )
  28.             $result.= $this->expirationDate->format('d-m-Y');
  29.         $result .='</td>';
  30.         if($displayCost){
  31.             $total $this->quantity*$this->cost;
  32.             $result.= '<td class="txt_a_c">'.number_format($total2',','.').' €</td></tr>';
  33.         }
  34.         else
  35.             $result .= '</tr>';
  36.         return $result;
  37.     }
  38.     /**
  39.      * @ORM\Column(name="id", type="bigint")
  40.      * @ORM\Id
  41.      * @ORM\GeneratedValue(strategy="AUTO")
  42.      */
  43.     protected $id;
  44.     /**
  45.      * @ORM\Column(name="quantity", type="string", length=191)
  46.      */
  47.     protected $quantity;
  48.     
  49.     /**
  50.      * @ORM\Column(name="activation_date", type="date", nullable=true)
  51.      */
  52.     protected $activationDate;
  53.     
  54.     /**
  55.      * @ORM\Column(name="expiration_date", type="date", nullable=true)
  56.      */
  57.     protected $expirationDate;
  58.     
  59.     /**
  60.      * @ORM\Column(name="cost", type="decimal", scale=2)
  61.      */
  62.     protected $cost;
  63.     
  64.     /**
  65.      * @ORM\Column(name="priority", type="integer")
  66.      */
  67.     protected $priority;
  68.     // ManyToOne
  69.         /**
  70.          * @ORM\ManyToOne(targetEntity="App\Entity\Master\Order", inversedBy="items")
  71.          * @ORM\JoinColumn(name="order_id", referencedColumnName="id")
  72.          */
  73.         private $order;
  74.         
  75.         /**
  76.          * @ORM\ManyToOne(targetEntity="App\Entity\Master\Feature", inversedBy="orderItems")
  77.          * @ORM\JoinColumn(name="feature_id", referencedColumnName="id")
  78.          */
  79.         private $feature;
  80.         
  81.         /**
  82.          * @ORM\ManyToOne(targetEntity="App\Entity\Master\Service", inversedBy="orderItems")
  83.          * @ORM\JoinColumn(name="service_id", referencedColumnName="id")
  84.          */
  85.         private $service;
  86.         public function getId(): ?string
  87.         {
  88.             return $this->id;
  89.         }
  90.         public function getQuantity(): ?string
  91.         {
  92.             return $this->quantity;
  93.         }
  94.         public function setQuantity(string $quantity): static
  95.         {
  96.             $this->quantity $quantity;
  97.             return $this;
  98.         }
  99.         public function getActivationDate(): ?\DateTimeInterface
  100.         {
  101.             return $this->activationDate;
  102.         }
  103.         public function setActivationDate(?\DateTimeInterface $activationDate): static
  104.         {
  105.             $this->activationDate $activationDate;
  106.             return $this;
  107.         }
  108.         public function getExpirationDate(): ?\DateTimeInterface
  109.         {
  110.             return $this->expirationDate;
  111.         }
  112.         public function setExpirationDate(?\DateTimeInterface $expirationDate): static
  113.         {
  114.             $this->expirationDate $expirationDate;
  115.             return $this;
  116.         }
  117.         public function getCost(): ?string
  118.         {
  119.             return $this->cost;
  120.         }
  121.         public function setCost(string $cost): static
  122.         {
  123.             $this->cost $cost;
  124.             return $this;
  125.         }
  126.         public function getPriority(): ?int
  127.         {
  128.             return $this->priority;
  129.         }
  130.         public function setPriority(int $priority): static
  131.         {
  132.             $this->priority $priority;
  133.             return $this;
  134.         }
  135.         public function getOrder(): ?Order
  136.         {
  137.             return $this->order;
  138.         }
  139.         public function setOrder(?Order $order): static
  140.         {
  141.             $this->order $order;
  142.             return $this;
  143.         }
  144.         public function getFeature(): ?Feature
  145.         {
  146.             return $this->feature;
  147.         }
  148.         public function setFeature(?Feature $feature): static
  149.         {
  150.             $this->feature $feature;
  151.             return $this;
  152.         }
  153.         public function getService(): ?Service
  154.         {
  155.             return $this->service;
  156.         }
  157.         public function setService(?Service $service): static
  158.         {
  159.             $this->service $service;
  160.             return $this;
  161.         }
  162. }