<?php
namespace App\Daikin\BaseBundle\Entity;
use App\Daikin\BaseBundle\Entity\Interfaces\CompanyInterface;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
use EHC\HTMLIdableBundle\Interfaces\HTMLIdableInterface;
use Gedmo\Mapping\Annotation as Gedmo;
/**
* @ORM\Entity
* @ORM\Table(name="objects")
*/
class Objects extends AbstractUserOwnedEntity implements HTMLIdableInterface, CompanyInterface
{
/**
* @ORM\Id
* @ORM\Column(type="integer")
* @ORM\GeneratedValue(strategy="AUTO")
*
* @var integer $id
*/
protected $id;
/**
* @Gedmo\Timestampable(on="create")
* @ORM\Column(type="integer", name="created_at")
*
* @var integer $createdAt
*/
protected $createdAt;
/**
* @Gedmo\Timestampable(on="update")
* @ORM\Column(type="integer", name="updated_at")
*
* @var integer $updatedAt
*/
protected $updatedAt;
/**
* @ORM\Column(type="integer", name="lastupdate")
*
* @var integer $lastupdate
*/
protected $lastupdate;
/**
* @ORM\Column(type="string", name="objectname")
*
* @var string $objectname
*/
protected $objectname;
/**
* @ORM\Column(type="string", name="contactperson", nullable=true)
*
* @var string $contactperson
*/
protected $contactperson;
/**
* @ORM\Column(type="string", name="phone", nullable=true)
*
* @var string $phone
*/
protected $phone;
/**
* @ORM\Column(type="string", name="address", nullable=true)
*
* @var string $address
*/
protected $address;
/**
* @ORM\Column(type="string", name="street", nullable=true)
*
* @var string $street
*/
protected $street;
/**
* @ORM\Column(length=6, nullable=true)
*
* @var integer $zip
*/
protected $zip;
/**
* @ORM\Column(type="string", name="city", nullable=true)
*
* @var string $city
*/
protected $city;
/**
* @ORM\Column(type="string", name="comment", nullable=true)
*
* @var string $comment
*/
protected $comment;
/**
* @ORM\Column(type="float", name="longitude", nullable=true)
*
* @var string $longitude
*/
protected $longitude;
/**
* @ORM\Column(type="float", name="latitude", nullable=true)
*
* @var string $latitude
*/
protected $latitude;
/**
* @ORM\OneToMany(targetEntity="Objectsunit", mappedBy="object")
*
* @var ArrayCollection $objectsunit
*/
protected $objectunits;
/**
* @ORM\ManyToOne(targetEntity="Company", inversedBy="objects")
* @ORM\JoinColumn(name="companyid", nullable=false)
*/
protected $company;
/**
* Constructs a new instance
*/
public function __construct()
{
parent::__construct();
$this->createdAt = time();
$this->updatedAt = time();
$this->objectunits = new ArrayCollection();
}
public function __toString()
{
return $this->getObjectname();
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
public function getHTMLId()
{
return 'object-'.$this->id;
}
/**
* Set createdAt
*
* @param integer $createdAt
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
}
/**
* Get createdAt
*
* @return integer
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param integer $updatedAt
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
}
/**
* Get updatedAt
*
* @return integer
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Set lastupdate
*
* @param integer $lastupdate
*/
public function setLastupdate($lastupdate)
{
$this->lastupdate = $lastupdate;
}
/**
* Get lastupdate
*
* @return integer
*/
public function getLastupdate()
{
return $this->lastupdate;
}
/**
* Set objectname
*
* @param string $objectname
*/
public function setObjectname($objectname)
{
$this->objectname = $objectname;
}
/**
* Get objectname
*
* @return string
*/
public function getObjectname()
{
return $this->objectname;
}
/**
* Set contactperson
*
* @param string $contactperson
*/
public function setContactperson($contactperson)
{
$this->contactperson = $contactperson;
}
/**
* Get contactperson
*
* @return string
*/
public function getContactperson()
{
return $this->contactperson;
}
/**
* Set phone
*
* @param string $phone
*/
public function setPhone($phone)
{
$this->phone = $phone;
}
/**
* Get phone
*
* @return string
*/
public function getPhone()
{
return $this->phone;
}
/**
* Generate address
*/
public function setAddress()
{
$this->address = $this->getStreet() . ', ' . $this->getZip() . ', ' . $this->getCity();
}
/**
* @param $address
* @return Objects
*/
public function overrideAddress($address)
{
$this->address = $address;
return $this;
}
/**
* Get address
*
* @return string
*/
public function getAddress()
{
return $this->address;
}
/**
* Set street
*
* @param string $street
*/
public function setStreet($street)
{
$this->street = $street;
}
/**
* Get street
*
* @return string
*/
public function getStreet()
{
return $this->street;
}
/**
* Set zip
*
* @param integer $zip
*/
public function setZip($zip)
{
$this->zip = $zip;
}
/**
* Get zip
*
* @return integer
*/
public function getZip()
{
return $this->zip;
}
/**
* Set city
*
* @param string $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* Get city
*
* @return string
*/
public function getCity()
{
return $this->city;
}
/**
* Set comment
*
* @param string $comment
*/
public function setComment($comment)
{
$this->comment = $comment;
}
/**
* Get comment
*
* @return string
*/
public function getComment()
{
return $this->comment;
}
/**
* Set longitude
*
* @param float $longitude
*/
public function setLongitude($longitude)
{
$this->longitude = $longitude;
}
/**
* Get longitude
*
* @return float
*/
public function getLongitude()
{
return $this->longitude;
}
/**
* Set latitude
*
* @param float $latitude
*/
public function setLatitude($latitude)
{
$this->latitude = $latitude;
}
/**
* Get latitude
*
* @return float
*/
public function getLatitude()
{
return $this->latitude;
}
/**
* Get objectunits
*
* @return ArrayCollection|Objectsunit[]
*/
public function getObjectunits()
{
return $this->objectunits;
}
/**
* set Company
*
* @param \App\Daikin\BaseBundle\Entity\Company $company
* @return \App\Daikin\BaseBundle\Entity\Objects
*/
public function setCompany(Company $company)
{
$this->company = $company;
return $this;
}
/**
* get Company
*
* @return \App\Daikin\BaseBundle\Entity\Company
*/
public function getCompany(): ?Company
{
return $this->company;
}
/**
* Get companyid
*
* @return integer
* @deprecated since version 2.1 - kept for compatibility
*/
public function getCompanyid()
{
return $this->getCompany()->getId();
}
/**
* set deleted for the Object - if true, will recursivley delete
*
* @param boolean $deleted
* @return Object
*/
public function setDeleted($deleted)
{
if ( (bool)$deleted )
{
foreach( $this->getObjectunits() as $objectunit )
{
$objectunit->setDeleted(true);
}
}
return parent::setDeleted($deleted);
}
}