<?php
namespace App\AtechNet\CoreBundle\Entity;
use App\AtechNet\CoreBundle\Repository\CustomerAddressRepository;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\Table as Table;
/**
* CustomerAddress
*
* @Table(name="customers__address")
* @Entity(repositoryClass=CustomerAddressRepository::class)
*/
class CustomerAddress extends AbstractEntity
{
/**
* @var string
*
* @Column(name="title", type="string", length=255, nullable=true)
*/
private $title;
/**
* @var int
*
* @Column(name="type", type="integer", nullable=true)
*/
private $type;
/**
* @var Customer
*
* @ManyToOne(targetEntity="Customer", inversedBy="addresses")
* @JoinColumn(name="customer_id", referencedColumnName="id")
*/
private $customer;
/**
* @var string
*
* @Column(name="first_name", type="string", length=255, nullable=true)
*/
private $firstName;
/**
* @var string
*
* @Column(name="last_name", type="string", length=255, nullable=true)
*/
private $lastName;
/**
* @var string
*
* @Column(name="business_name", type="string", length=255, nullable=true)
*/
private $businessName;
/**
* @var string
*
* @Column(name="street", type="string", length=255)
*/
private $street;
/**
* @var string
*
* @Column(name="city", type="string", length=255)
*/
private $city;
/**
* @var string
*
* @Column(name="zip", type="string", length=255)
*/
private $zip;
/**
* @var string
*
* @Column(name="district", type="string", length=255)
*/
private $district = '';
/**
* @var string
*
* @Column(name="country", type="string", length=255)
*/
private $country;
/**
* @var string
*
* @Column(name="phone_number", type="string", length=255, nullable=true)
*/
private $phone;
/**
* @var string
*
* @Column(name="email", type="string", length=255, nullable=true)
*/
private $email;
/**
* @var string
*
* @Column(name="gps", type="string", length=255, nullable=true)
*/
private $gps;
public const AddressType_Billing = 'billing';
public const AddressType_Shipping = 'shipping';
public const AddressType_Billing_Id = 0;
public const AddressType_Shipping_Id = 1;
public const EU_COUNTRIES = [
'AT' => 'Austria',
'BE' => 'Belgium',
'BG' => 'Bulgaria',
'HR' => 'Croatia',
'CY' => 'Cyprus',
'DK' => 'Denmark',
'EE' => 'Estonia',
'FI' => 'Finland',
'FR' => 'France',
'DE' => 'Germany',
'GR' => 'Greece',
'IE' => 'Ireland',
'IT' => 'Italy',
'LV' => 'Latvia',
'LT' => 'Lithuania',
'LU' => 'Luxemburg',
'MT' => 'Malta',
'NL' => 'Nederlands',
'PL' => 'Poland',
'PT' => 'Portugal',
'RO' => 'Romania',
'SI' => 'Slovenia',
'ES' => 'Spain',
'SE' => 'Sweden',
'HU' => 'Hungary',
];
/**
* Returns the address types in array
*
* @return array
*/
public static function getAddressTypes()
{
return [
self::AddressType_Billing,
self::AddressType_Shipping,
];
}
public static function getCountries()
{
return [
'SK' => 'Slovenská republika',
'HU' => 'Magyarország',
'CZ' => 'Česká republika',
];
}
/**
* @return int
*/
public function getType()
{
return $this->type;
}
/**
* @param int $type
*/
public function setType($type)
{
$this->type = $type;
}
/**
* @return Customer
*/
public function getCustomer()
{
return $this->customer;
}
/**
* @param Customer $customer
*/
public function setCustomer($customer)
{
$this->customer = $customer;
}
/**
* Set title
*
* @param string $title
* @return $this
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get title
*
* @return string
*/
public function getTitle()
{
return $this->title;
}
/**
* Set firstName
*
* @param string $firstName
* @return string
*/
public function setFirstName($firstName)
{
$this->firstName = ucfirst($firstName);
return $this;
}
/**
* Get firstName
*
* @return string
*/
public function getFirstName()
{
return $this->firstName;
}
/**
* Set lastName
*
* @param string $lastName
* @return string
*/
public function setLastName($lastName)
{
$this->lastName = ucfirst($lastName);
return $this;
}
/**
* Get lastName
*
* @return string
*/
public function getLastName()
{
return $this->lastName;
}
/**
* Set businessTitle
*
* @param string $businessName
* @return string
*/
public function setBusinessName($businessName)
{
$this->businessName = $businessName;
return $this;
}
/**
* Get businessTitle
*
* @return string
*/
public function getBusinessName()
{
return $this->businessName;
}
/**
* Set street
*
* @param string $street
* @return CustomerAddress
*/
public function setStreet($street)
{
$this->street = $street;
return $this;
}
/**
* Get street
*
* @return string
*/
public function getStreet()
{
return $this->street;
}
/**
* Set city
*
* @param string $city
* @return CustomerAddress
*/
public function setCity($city)
{
$this->city = $city;
return $this;
}
/**
* Get city
*
* @return string
*/
public function getCity()
{
return $this->city;
}
/**
* Set zip
*
* @param string $zip
* @return CustomerAddress
*/
public function setZip($zip)
{
$this->zip = $zip;
return $this;
}
/**
* Get zip
*
* @return string
*/
public function getZip()
{
return $this->zip;
}
/**
* Set district
*
* @param string $district
* @return CustomerAddress
*/
public function setDistrict($district)
{
$this->district = $district;
return $this;
}
/**
* Get district
*
* @return string
*/
public function getDistrict()
{
return $this->district;
}
/**
* Set country
*
* @param string $country
* @return CustomerAddress
*/
public function setCountry($country)
{
$this->country = $country;
return $this;
}
/**
* Get country
*
* @return string
*/
public function getCountry()
{
return $this->country;
}
/**
* Set phoneNumber
*
* @param string $phone
* @return string
*/
public function setPhone($phone)
{
$this->phone = $phone;
return $this;
}
/**
* Get phone
*
* @return string
*/
public function getPhone()
{
return $this->phone;
}
/**
* @return string
*/
public function getEmail()
{
return $this->email;
}
/**
* @param string $email
*/
public function setEmail($email)
{
$this->email = $email;
return $this;
}
/**
* Set gps
*
* @param string $gps
* @return CustomerAddress
*/
public function setGps($gps)
{
$this->gps = $gps;
return $this;
}
/**
* Get gps
*
* @return string
*/
public function getGps()
{
return $this->gps;
}
public function checkRequiredFields()
{
if ($this->getCustomer() != null
&& $this->getFirstName() != null && $this->getFirstName() != ''
&& $this->getLastName() != null && $this->getLastName() != ''
&& $this->getStreet() != null && $this->getStreet() != ''
&& $this->getCity() != null && $this->getCity() != ''
&& $this->getZip() != null && $this->getZip() != '') {
return true;
} else {
return false;
}
}
/**
* Return full name of $this address
*
* @return string
*/
public function getFullName()
{
$fullName = '';
if ($this->getFirstName() != null && $this->getFirstName() != '') {
$fullName = $this->getFirstName();
}
if ($this->getLastName() != null && $this->getLastName() != '') {
$fullName .= ' ' . $this->getLastName();
}
return $fullName;
}
}