src/Entity/Master/License.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_license")
  9.  * @ORM\Entity(repositoryClass="App\Repository\Master\LicenseRepository")
  10.  */
  11. class License
  12. {
  13.     public function getIsActive()
  14.     {
  15.         $expirationDate = clone($this->getActivationDate());
  16.         date_modify($expirationDate"+1 Years");
  17.         $now = new \DateTime();
  18.         if($this->isAdminActive && $expirationDate->format("Ymd") > $now->format("Ymd"))
  19.             return true;
  20.         return false;
  21.     }
  22.     
  23.     public function getDisplayFeatures()
  24.     {
  25.         $result '<table class="table table-sm b_none"><thead><tr><th class="td_w_300p"><ass="form_label m_b_none">Nome</label></th><th class="td_w_130p txt_a_c"><label class="form_label m_b_none">Data attivazione</label></th><th class="td_w_130p txt_a_c"><label class="form_label m_b_none">Data scadenza</label></th></tr></thead><tbody>';
  26.         foreach($this->getFeatures() as $jtlf){
  27.             $result.= '<tr><td>'.$jtlf->getFeature()->getName().'</td><td class="txt_a_c">'.$jtlf->getActivationDate()->format('d-m-Y').'</td><td class="txt_a_c">'.$jtlf->getExpirationDate()->format('d-m-Y').'</td></tr>';
  28.         }
  29.         $result.= '</tbody></table>';
  30.         return $result;
  31.     }
  32.     /**
  33.      * @ORM\Column(name="id", type="bigint")
  34.      * @ORM\Id
  35.      * @ORM\GeneratedValue(strategy="AUTO")
  36.      */
  37.     protected $id;
  38.         
  39.     /**
  40.      * @ORM\Column(name="active", type="boolean")
  41.      */
  42.     protected $active true;
  43.     
  44.     /**
  45.      * @ORM\Column(name="activation_date", type="date", nullable=true)
  46.      */
  47.     protected $activationDate;
  48.     
  49.     /**
  50.      * @ORM\Column(name="expiration_date", type="date", nullable=true)
  51.      */
  52.     protected $expirationDate;
  53.     
  54.     /**
  55.      * @ORM\Column(name="contract_path", type="string", length=191, nullable=true)
  56.      */
  57.     protected $contractPath;
  58.     // ManyToOne
  59.         /**
  60.          * @ORM\ManyToOne(targetEntity="App\Entity\Master\Company", inversedBy="licenses")
  61.          * @ORM\JoinColumn(name="company_id", referencedColumnName="id")
  62.          */
  63.         private $company;
  64.     //
  65.     
  66.     // OneToMany
  67.         /**
  68.          * @ORM\OneToMany(targetEntity="App\Entity\Master\JoinTableLicenseFeature", mappedBy="license")
  69.          */
  70.         private $features;
  71.     //
  72.     public function __construct()
  73.     {
  74.         $this->features = new ArrayCollection();
  75.     }
  76.     public function getId(): ?string
  77.     {
  78.         return $this->id;
  79.     }
  80.     public function isActive(): ?bool
  81.     {
  82.         return $this->active;
  83.     }
  84.     public function setActive(bool $active): self
  85.     {
  86.         $this->active $active;
  87.         return $this;
  88.     }
  89.     public function getActivationDate(): ?\DateTimeInterface
  90.     {
  91.         return $this->activationDate;
  92.     }
  93.     public function setActivationDate(?\DateTimeInterface $activationDate): self
  94.     {
  95.         $this->activationDate $activationDate;
  96.         return $this;
  97.     }
  98.     public function getExpirationDate(): ?\DateTimeInterface
  99.     {
  100.         return $this->expirationDate;
  101.     }
  102.     public function setExpirationDate(?\DateTimeInterface $expirationDate): self
  103.     {
  104.         $this->expirationDate $expirationDate;
  105.         return $this;
  106.     }
  107.     public function getCompany(): ?Company
  108.     {
  109.         return $this->company;
  110.     }
  111.     public function setCompany(?Company $company): self
  112.     {
  113.         $this->company $company;
  114.         return $this;
  115.     }
  116.     /**
  117.      * @return Collection<int, JoinTableLicenseFeature>
  118.      */
  119.     public function getFeatures(): Collection
  120.     {
  121.         return $this->features;
  122.     }
  123.     public function addFeature(JoinTableLicenseFeature $feature): self
  124.     {
  125.         if (!$this->features->contains($feature)) {
  126.             $this->features->add($feature);
  127.             $feature->setLicense($this);
  128.         }
  129.         return $this;
  130.     }
  131.     public function removeFeature(JoinTableLicenseFeature $feature): self
  132.     {
  133.         if ($this->features->removeElement($feature)) {
  134.             // set the owning side to null (unless already changed)
  135.             if ($feature->getLicense() === $this) {
  136.                 $feature->setLicense(null);
  137.             }
  138.         }
  139.         return $this;
  140.     }
  141.     public function getContractPath(): ?string
  142.     {
  143.         return $this->contractPath;
  144.     }
  145.     public function setContractPath(?string $contractPath): self
  146.     {
  147.         $this->contractPath $contractPath;
  148.         return $this;
  149.     }
  150. }