<?php
namespace App\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\LeadRepository")
*/
class Lead
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="leads", cascade={"persist"})
* @ORM\JoinColumn(name="user_id", referencedColumnName="id", onDelete="CASCADE", nullable=true)
*/
private $user;
/**
* @ORM\Column(type="string", length=40)
*/
private $ip_address;
/**
* @ORM\Column(type="string", length=64)
*/
private $firstname;
/**
* @ORM\Column(type="string", length=64)
*/
private $lastname;
/**
* @ORM\Column(type="string", length=64)
*/
private $company;
/**
* @ORM\Column(type="string", length=64)
*/
private $job_title;
/**
* @ORM\Column(type="string", length=128)
*/
private $email;
/**
* @ORM\Column(type="string", length=15)
*/
private $phone_business;
/**
* @ORM\Column(type="string", length=15)
*/
private $phone_mobile;
/**
* @ORM\Column(type="string", length=64)
*/
private $address1;
/**
* @ORM\Column(type="string", length=64)
*/
private $address2;
/**
* @ORM\Column(type="string", length=32)
*/
private $city;
/**
* @ORM\Column(type="string", length=24)
*/
private $state;
/**
* @ORM\Column(type="string", length=10)
*/
private $zip;
/**
* @ORM\Column(type="string", length=4)
*/
private $last4;
/**
* @ORM\Column(type="string", length=48)
*/
private $country;
/**
* @ORM\Column(type="string", length=64)
*/
private $website;
/**
* @ORM\Column(type="string", length=24)
*/
private $type_business;
/**
* @ORM\Column(type="string", length=24)
*/
private $type_work;
/**
* @ORM\Column(type="datetime")
*/
private $year_established;
/**
* @ORM\Column(type="integer")
*/
private $employee_size;
/**
* @ORM\Column(type="string", length=8)
*/
private $gender;
/**
* @ORM\Column(type="string", length=24)
*/
private $ethnicity;
/**
* @ORM\Column(type="string", length=64)
*/
private $language;
/**
* @ORM\Column(type="decimal", precision=10, scale=0)
*/
private $sales_volume;
/**
* @ORM\Column(type="string", length=64)
*/
private $contractor_specialty;
/**
* @ORM\Column(type="string", length=64)
*/
private $products_services_specialty;
/**
* @ORM\Column(type="string", length=64)
*/
private $rcs_user;
/**
* @ORM\Column(type="string", length=128)
*/
private $ref_url;
/**
* @ORM\Column(type="string", length=196)
*/
private $user_agent;
/**
* @ORM\Column(type="datetime")
*/
private $created_at;
/**
* @ORM\Column(type="datetime")
*/
private $birthday;
/**
* @ORM\Column(type="text")
*/
private $comments;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Content", inversedBy="leads", cascade={"persist"})
* @ORM\JoinColumn(name="content_id", referencedColumnName="id", onDelete="CASCADE")
*/
private $content;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Contact", inversedBy="leads", cascade={"persist"})
* @ORM\JoinColumn(name="contact_id", referencedColumnName="id", nullable=true)
*/
private $contact;
/**
* @ORM\Column(type="integer", nullable=true)
*/
private $old_client_id;
public function __construct()
{
$this->ip_address = "";
$this->firstname = "";
$this->lastname = "";
$this->company = "";
$this->job_title = "";
$this->email = "";
$this->phone_business = "";
$this->phone_mobile = "";
$this->address1 = "";
$this->address2 = "";
$this->city = "";
$this->state = "";
$this->zip = "";
$this->last4 = "";
$this->country = "";
$this->website = "";
$this->type_business = "";
$this->type_work = "";
$this->year_established = new \DateTime();
$this->employee_size = 0;
$this->gender = "";
$this->ethnicity = "";
$this->language = "";
$this->sales_volume = 0;
$this->contractor_specialty = "";
$this->products_services_specialty = "";
$this->rcs_user = "";
$this->ref_url = "";
$this->user_agent = "";
$this->created_at = new \DateTime();
$this->birthday = null;
$this->comments = "";
$this->old_client_id = null;
}
public function getId()
{
return $this->id;
}
public function getUser(): ?User
{
return $this->user;
}
public function setUser(?User $user = null): self
{
$this->user = $user;
return $this;
}
public function getContent(): ?Content
{
return $this->content;
}
public function setContent(?Content $content): self
{
$this->content = $content;
return $this;
}
public function getContact(): ?Contact
{
return $this->contact;
}
public function setContact(?Contact $contact = null): self
{
$this->contact = $contact;
return $this;
}
public function getIpAddress(): ?string
{
return $this->ip_address;
}
public function setIpAddress(string $ip_address = null): self
{
if (is_null($ip_address)) {
$ip_address = "";
}
$this->ip_address = $ip_address;
return $this;
}
public function getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname = null): self
{
if (is_null($firstname)) {
$firstname = "";
}
$this->firstname = $firstname;
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname = null): self
{
if (is_null($lastname)) {
$lastname = "";
}
$this->lastname = $lastname;
return $this;
}
public function getCompany(): ?string
{
return $this->company;
}
public function setCompany(string $company = null): self
{
if (is_null($company)) {
$company = "";
}
$this->company = $company;
return $this;
}
public function getJobTitle(): ?string
{
return $this->job_title;
}
public function setJobTitle(string $job_title = null): self
{
if (is_null($job_title)) {
$job_title = "";
}
$this->job_title = $job_title;
return $this;
}
public function getEmail(): ?string
{
return $this->email;
}
public function setEmail(string $email = null): self
{
if (is_null($email)) {
$email = "";
}
$this->email = $email;
return $this;
}
public function getPhoneBusiness(): ?string
{
return $this->phone_business;
}
public function setPhoneBusiness(string $phone_business = null): self
{
if (is_null($phone_business)) {
$phone_business = "";
}
$this->phone_business = $phone_business;
return $this;
}
public function getPhoneMobile(): ?string
{
return $this->phone_mobile;
}
public function setPhoneMobile(string $phone_mobile = null): self
{
if (is_null($phone_mobile)) {
$phone_mobile = "";
}
$this->phone_mobile = $phone_mobile;
return $this;
}
public function getAddress1(): ?string
{
return $this->address1;
}
public function setAddress1(string $address1 = null): self
{
if (is_null($address1)) {
$address1 = "";
}
$this->address1 = $address1;
return $this;
}
public function getAddress2(): ?string
{
return $this->address2;
}
public function setAddress2(string $address2 = null): self
{
if (is_null($address2)) {
$address2 = "";
}
$this->address2 = $address2;
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city = null): self
{
if (is_null($city)) {
$city = "";
}
$this->city = $city;
return $this;
}
public function getState(): ?string
{
return $this->state;
}
public function setState(string $state = ""): self
{
if (is_null($state)) {
$state = "";
}
$this->state = $state;
return $this;
}
public function getZip(): ?string
{
return $this->zip;
}
public function setZip(string $zip = null): self
{
if (is_null($zip)) {
$zip = "";
}
$this->zip = $zip;
return $this;
}
public function getLast4(): ?string
{
return $this->last4;
}
public function setLast4(string $last4 = null): self
{
if (is_null($last4)) {
$last4 = "";
}
$this->last4 = $last4;
return $this;
}
public function getCountry(): ?string
{
return $this->country;
}
public function setCountry(string $country = null): self
{
if (is_null($country)) {
$country = "";
}
$this->country = $country;
return $this;
}
public function getWebsite(): ?string
{
return $this->website;
}
public function setWebsite(string $website = null): self
{
if (is_null($website)) {
$website = "";
}
$this->website = $website;
return $this;
}
public function getTypeBusiness(): ?string
{
return $this->type_business;
}
public function setTypeBusiness(string $type_business = ""): self
{
if (is_null($type_business)) {
$type_business = "";
}
$this->type_business = $type_business;
return $this;
}
public function getTypeWork(): ?string
{
return $this->type_work;
}
public function setTypeWork(string $type_work = null): self
{
if (is_null($type_work)) {
$type_work = "";
}
$this->type_work = $type_work;
return $this;
}
public function getYearEstablished(): ?\DateTimeInterface
{
return $this->year_established;
}
public function setYearEstablished(\DateTimeInterface $year_established = null): self
{
if (is_null($year_established)) {
$year_established = new \DateTime("now");
}
$this->year_established = $year_established;
return $this;
}
public function getEmployeeSize(): ?int
{
return $this->employee_size;
}
public function setEmployeeSize(int $employee_size = null): self
{
if (is_null($employee_size)) {
$employee_size = 0;
}
$this->employee_size = $employee_size;
return $this;
}
public function getGender(): ?string
{
return $this->gender;
}
public function setGender(string $gender = null): self
{
if (is_null($gender)) {
$gender = "";
}
$this->gender = $gender;
return $this;
}
public function getEthnicity(): ?string
{
return $this->ethnicity;
}
public function setEthnicity(string $ethnicity = null): self
{
if (is_null($ethnicity)) {
$ethnicity = "";
}
$this->ethnicity = $ethnicity;
return $this;
}
public function getLanguage(): ?string
{
return $this->language;
}
public function setLanguage(string $language = null): self
{
if (is_null($language)) {
$language = "";
}
$this->language = $language;
return $this;
}
public function getSalesVolume()
{
return $this->sales_volume;
}
public function setSalesVolume($sales_volume = null): self
{
if (is_null($sales_volume)) {
$sales_volume = 0;
}
$this->sales_volume = $sales_volume;
return $this;
}
public function getContractorSpecialty(): ?string
{
return $this->contractor_specialty;
}
public function setContractorSpecialty(string $contractor_specialty = null): self
{
if (is_null($contractor_specialty)) {
$contractor_specialty = "";
}
$this->contractor_specialty = $contractor_specialty;
return $this;
}
public function getProductsServicesSpecialty(): ?string
{
return $this->products_services_specialty;
}
public function setProductsServicesSpecialty(string $products_services_specialty = null): self
{
if (is_null($products_services_specialty)) {
$products_services_specialty = "";
}
$this->products_services_specialty = $products_services_specialty;
return $this;
}
public function getRcsUser(): ?string
{
return $this->rcs_user;
}
public function setRcsUser(string $rcs_user = null): self
{
if (is_null($rcs_user)) {
$rcs_user = "";
}
$this->rcs_user = $rcs_user;
return $this;
}
public function getRefUrl(): ?string
{
return $this->ref_url;
}
public function setRefUrl(string $ref_url = null): self
{
if (is_null($ref_url)) {
$ref_url = "";
}
$this->ref_url = $ref_url;
return $this;
}
public function getUserAgent(): ?string
{
return $this->user_agent;
}
public function setUserAgent(string $user_agent = null): self
{
if (is_null($user_agent)) {
$user_agent = "";
}
$this->user_agent = $user_agent;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->created_at;
}
public function setCreatedAt(\DateTimeInterface $created_at = null): self
{
if (is_null($created_at)) {
$created_at = new \DateTime("now");
}
$this->created_at = $created_at;
return $this;
}
public function getBirthday(): ?\DateTimeInterface
{
return $this->birthday;
}
public function setBirthday(\DateTimeInterface $birthday = null): self
{
$this->birthday = $birthday;
return $this;
}
public function getComments(): ?string
{
return $this->comments;
}
public function setComments(string $comments = null): self
{
if (is_null($comments)) {
$comments = "";
}
$this->comments = $comments;
return $this;
}
//Comments are being used to store custom fields. This function returns them as an assoc array.
public function getCustomFields(): ?array
{
$return = null;
if($this->comments) {
$return = json_decode($this->comments, true);
//Format the field title
if($return) {
if(isset($return["custom_fields"])) {
//new way of storing
$return = $return["custom_fields"];
}
foreach($return as $key => $value) {
unset($return[$key]);
$return[ucwords(str_replace("_", " ", $key))] = $value;
}
}
else {
//Not json_encoded, just normal comments
$return = [
"Comments" => $this->comments
];
}
}
return $return;
}
public function getCustomFieldMediaIDs(): ?array
{
$return = null;
if($this->comments) {
$return = json_decode($this->comments, true);
if($return) {
if(isset($return["custom_media_ids"])) {
$return = $return["custom_media_ids"];
foreach($return as $key => $value) {
unset($return[$key]);
$return[ucwords(str_replace("_", " ", $key))] = $value;
}
}
}
}
return $return;
}
public function getOldClientId(): ?int
{
return $this->old_client_id;
}
public function setOldClientId(int $old_client_id): self
{
$this->old_client_id = $old_client_id;
return $this;
}
public function __toString ()
{
if($this->firstname) {
$return = $this->firstname;
if($this->lastname)
{
$return .= " " . $this->lastname;
}
return $return;
}
return $this->email ? $this->email : '';
}
}