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.     //
  87.     public function getId(): ?string
  88.     {
  89.         return $this->id;
  90.     }
  91.     public function getQuantity(): ?string
  92.     {
  93.         return $this->quantity;
  94.     }
  95.     public function setQuantity(string $quantity): self
  96.     {
  97.         $this->quantity $quantity;
  98.         return $this;
  99.     }
  100.     public function getActivationDate(): ?\DateTimeInterface
  101.     {
  102.         return $this->activationDate;
  103.     }
  104.     public function setActivationDate(?\DateTimeInterface $activationDate): self
  105.     {
  106.         $this->activationDate $activationDate;
  107.         return $this;
  108.     }
  109.     public function getExpirationDate(): ?\DateTimeInterface
  110.     {
  111.         return $this->expirationDate;
  112.     }
  113.     public function setExpirationDate(?\DateTimeInterface $expirationDate): self
  114.     {
  115.         $this->expirationDate $expirationDate;
  116.         return $this;
  117.     }
  118.     public function getCost(): ?string
  119.     {
  120.         return $this->cost;
  121.     }
  122.     public function setCost(string $cost): self
  123.     {
  124.         $this->cost $cost;
  125.         return $this;
  126.     }
  127.     public function getPriority(): ?int
  128.     {
  129.         return $this->priority;
  130.     }
  131.     public function setPriority(int $priority): self
  132.     {
  133.         $this->priority $priority;
  134.         return $this;
  135.     }
  136.     public function getOrder(): ?Order
  137.     {
  138.         return $this->order;
  139.     }
  140.     public function setOrder(?Order $order): self
  141.     {
  142.         $this->order $order;
  143.         return $this;
  144.     }
  145.     public function getFeature(): ?Feature
  146.     {
  147.         return $this->feature;
  148.     }
  149.     public function setFeature(?Feature $feature): self
  150.     {
  151.         $this->feature $feature;
  152.         return $this;
  153.     }
  154.     public function getService(): ?Service
  155.     {
  156.         return $this->service;
  157.     }
  158.     public function setService(?Service $service): self
  159.     {
  160.         $this->service $service;
  161.         return $this;
  162.     }
  163. }