<?php
namespace Diplix\KMGBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Imagine\Exception\NotSupportedException;
use Symfony\Component\PropertyAccess\PropertyAccess;
/**
* @ORM\Table(name="addresses", indexes={@ORM\Index(name="be_deleted",columns={"be_deleted"})})
* @ORM\Entity(repositoryClass="Diplix\KMGBundle\Repository\AddressRepository", )
*/
class Address extends BasicEntity implements \JsonSerializable
{
const WAYPOINT_IN = "Einstieg";
const WAYPOINT_OUT = "Ausstieg";
/**
* @ORM\Column(type="integer",name="id")
* @ORM\Id()
* @ORM\GeneratedValue(strategy="AUTO")
*/
protected $id;
/**
* @ORM\ManyToOne(targetEntity="Order", inversedBy="addressList")
* @ORM\JoinColumn(referencedColumnName="id")
*/
protected $owningOrder;
/**
* @ORM\Column(type="string")
*/
protected $waypointType = self::WAYPOINT_IN;
/**
* @ORM\Column(type="string")
*/
protected $name;
/**
* @ORM\Column(type="string")
*/
protected $passenger="";
/**
* @ORM\Column(type="string")
*/
protected $street;
/**
* @ORM\Column(type="string")
*/
protected $number;
/**
* @ORM\Column(type="string")
*/
protected $zipCode;
/**
* @ORM\Column(type="string")
*/
protected $city;
/**
* @ORM\Column(type="string")
*/
protected $mobileNumber = "";
/**
* @ORM\Column(type="string")
*/
protected $creditCardNo = "";
/**
* @ORM\Column(type="string")
*/
protected $creditCardMonth = "";
/**
* @ORM\Column(type="string")
*/
protected $creditCardYear = "";
/**
* A address may be assigned to a customer, but it doesn't have to
* @ORM\ManyToOne(targetEntity="Customer")
* @ORM\JoinColumn(name="customer_id",nullable=true)
*/
protected $customer;
/**
* @ORM\Column(type="integer")
*/
protected $sortOrder = 0;
/**
* @ORM\ManyToOne(targetEntity="Diplix\KMGBundle\Entity\AddressType")
* @ORM\JoinColumn(referencedColumnName="id")
*/
protected $addressType;
/**
* @ORM\Column(type="string")
*/
protected $email = "";
/**
* @ORM\Column(type="boolean", options={"default"="0"})
*/
protected $fixedBySystem = false;
public function __construct($customer=null, $sortOrder=0)
{
$this->setCustomer($customer);
$this->setSortOrder($sortOrder);
}
public function __clone()
{
$this->owningOrder = null;
$this->id = null;
}
/**
* @return mixed
*/
public function getId()
{
return $this->id;
}
/**
* @return mixed
*/
public function getOwningOrder()
{
return $this->owningOrder;
}
/**
* @param mixed $owningOrder
*/
public function setOwningOrder($owningOrder)
{
$this->owningOrder = $owningOrder;
}
/**
* @return mixed
*/
public function getWaypointType()
{
return $this->waypointType;
}
/**
* @param mixed $waypointType
*/
public function setWaypointType($waypointType)
{
$this->waypointType = $waypointType;
}
/**
* @return mixed
*/
public function getName()
{
return $this->name;
}
/**
* @param mixed $name
*/
public function setName($name)
{
$this->name = $name;
}
/**
* @return mixed
*/
public function getStreet()
{
return $this->street;
}
/**
* @param mixed $street
*/
public function setStreet($street)
{
$this->street = $street;
}
/**
* @return mixed
*/
public function getNumber()
{
return $this->number;
}
/**
* @param mixed $number
*/
public function setNumber($number)
{
$this->number = $number;
}
/**
* @return mixed
*/
public function getZipCode()
{
return $this->zipCode;
}
/**
* @param mixed $zipCode
*/
public function setZipCode($zipCode)
{
$this->zipCode = $zipCode;
}
/**
* @return mixed
*/
public function getCity()
{
return $this->city;
}
/**
* @param mixed $city
*/
public function setCity($city)
{
$this->city = $city;
}
/**
* @return mixed
*/
public function getCustomer()
{
return $this->customer;
}
/**
* @param mixed $customer
*/
public function setCustomer($customer)
{
$this->customer = $customer;
}
/**
* @return mixed
*/
public function getSortOrder()
{
return $this->sortOrder;
}
/**
* @param mixed $sortOrder
*/
public function setSortOrder($sortOrder)
{
$this->sortOrder = $sortOrder;
}
/**
* @return mixed
*/
public function getPassenger()
{
return $this->passenger;
}
/**
* @param mixed $passenger
*/
public function setPassenger($passenger)
{
$this->passenger = $passenger;
}
/**
* @return AddressType
*/
public function getAddressType()
{
return $this->addressType;
}
/**
* @param AddressType $addressType
*/
public function setAddressType($addressType)
{
$this->addressType = $addressType;
}
/**
* @return mixed
*/
public function getMobileNumber()
{
return $this->mobileNumber;
}
/**
* @param mixed $mobileNumber
*/
public function setMobileNumber($mobileNumber)
{
$this->mobileNumber = $mobileNumber;
}
/**
* @return mixed
*/
public function getCreditCardNo()
{
return $this->creditCardNo;
}
/**
* @param mixed $creditCardNo
*/
public function setCreditCardNo($creditCardNo)
{
$this->creditCardNo = $creditCardNo;
}
/**
* @return mixed
*/
public function getCreditCardMonth()
{
return $this->creditCardMonth;
}
/**
* @param mixed $creditCardMonth
*/
public function setCreditCardMonth($creditCardMonth)
{
$this->creditCardMonth = $creditCardMonth;
}
/**
* @return mixed
*/
public function getCreditCardYear()
{
return $this->creditCardYear;
}
/**
* @param mixed $creditCardYear
*/
public function setCreditCardYear($creditCardYear)
{
$this->creditCardYear = $creditCardYear;
}
/**
* @return mixed
*/
public function getEmail()
{
return $this->email;
}
/**
* @param mixed $email
*/
public function setEmail($email)
{
$this->email = $email;
}
/**
* @return boolean
*/
public function getFixedBySystem()
{
return $this->fixedBySystem;
}
/**
* @param boolean $fixedBySystem
*/
public function setFixedBySystem($fixedBySystem)
{
$this->fixedBySystem = $fixedBySystem;
}
/**
* Specify data which should be serialized to JSON
* @link http://php.net/manual/en/jsonserializable.jsonserialize.php
* @return mixed data which can be serialized by <b>json_encode</b>,
* which is a value of any type other than a resource.
* @since 5.4.0
*/
function jsonSerialize($prefix = "")
{
return [
$prefix."email" => $this->getEmail(),
$prefix."street" => $this->getStreet(),
$prefix."number" => $this->getNumber(),
$prefix."city"=> $this->getCity(),
$prefix."zipCode" => $this->getZipCode(),
$prefix."name"=>$this->getName(),
$prefix."passenger"=>$this->getPassenger(),
$prefix."sortOrder"=>$this->getSortOrder(),
$prefix."mobileNumber"=>$this->getMobileNumber(),
];
}
function fromJson(array $data)
{
$pp = PropertyAccess::createPropertyAccessor();
foreach(["email","street","number","city","zipCode","name","passenger","sortOrder","mobileNumber"] as $k)
{
if (isset($data[$k]))
{
$pp->setValue($this,$k,$data[$k]);
}
}
}
}