<?php
namespace App\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\ContactRepository")
*/
class Contact
{
const STATUS_SPAM = -1;
const STATUS_INACTIVE = 0;
const STATUS_ACTIVE = 1;
const LIST_OF_STATES = [
"AL" => "Alabama",
"AK" => "Alaska",
"AZ" => "Arizona",
"AR" => "Arkansas",
"CA" => "California",
"CO" => "Colorado",
"CT" => "Connecticut",
"DE" => "Delaware",
"FL" => "Florida",
"GA" => "Georgia",
"HI" => "Hawaii",
"ID" => "Idaho",
"IL" => "Illinois",
"IN" => "Indiana",
"IA" => "Iowa",
"KS" => "Kansas",
"KY" => "Kentucky",
"LA" => "Louisiana",
"ME" => "Maine",
"MD" => "Maryland",
"MA" => "Massachusetts",
"MI" => "Michigan",
"MN" => "Minnesota",
"MS" => "Mississippi",
"MO" => "Missouri",
"MT" => "Montana",
"NE" => "Nebraska",
"NV" => "Nevada",
"NH" => "New Hampshire",
"NJ" => "New Jersey",
"NM" => "New Mexico",
"NY" => "New York",
"NC" => "North Carolina",
"ND" => "North Dakota",
"OH" => "Ohio",
"OK" => "Oklahoma",
"OR" => "Oregon",
"PA" => "Pennsylvania",
"RI" => "Rhode Island",
"SC" => "South Carolina",
"SD" => "South Dakota",
"TN" => "Tennessee",
"TX" => "Texas",
"UT" => "Utah",
"VT" => "Vermont",
"VA" => "Virginia",
"WA" => "Washington",
"WV" => "West Virginia",
"WI" => "Wisconsin",
"WY" => "Wyoming",
"AS" => "American Samoa",
"GU" => "Guam",
"MP" => "Northern Mariana Islands",
"PR" => "Puerto Rico",
"VI" => "US Virgin Islands",
"DC" => "Washington, DC",
"CA-AB" => "Alberta",
"CA-BC" => "British Columbia",
"CA-MB" => "Manitoba",
"CA-NB" => "New Brunswick",
"CA-NL" => "Newfoundland and Labrador",
"CA-NT" => "Northwest Territories",
"CA-NS" => "Nova Scotia",
"CA-NU" => "Nunavut",
"CA-ON" => "Ontario",
"CA-PE" => "Prince Edward Island",
"CA-QC" => "Quebec",
"CA-SK" => "Saskatchewan",
"CA-YT" => "Yukon",
"MX-AG" => "Aguascalientes",
"MX-BC" => "Baja California",
"MX-BS" => "Baja California Sur",
"MX-CH" => "Chihuahua",
"MX-CL" => "Colima",
"MX-CM" => "Campeche",
"MX-CO" => "Coahuila",
"MX-CS" => "Chiapas",
"MX-DF" => "Federal District",
"MX-DG" => "Durango",
"MX-GR" => "Guerrero",
"MX-GT" => "Guanajuato",
"MX-HG" => "Hidalgo",
"MX-JA" => "Jalisco",
"MX-ME" => "México State",
"MX-MI" => "Michoacán",
"MX-MO" => "Morelos",
"MX-NA" => "Nayarit",
"MX-NL" => "Nuevo León",
"MX-OA" => "Oaxaca",
"MX-PB" => "Puebla",
"MX-QE" => "Querétaro",
"MX-QR" => "Quintana Roo",
"MX-SI" => "Sinaloa",
"MX-SL" => "San Luis Potosí",
"MX-SO" => "Sonora",
"MX-TB" => "Tabasco",
"MX-TL" => "Tlaxcala",
"MX-TM" => "Tamaulipas",
"MX-VE" => "Veracruz",
"MX-YU" => "Yucatán",
"MX-ZA" => "Zacatecas",
];
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="App\Entity\Contact", inversedBy="children")
* @ORM\JoinColumn(nullable=true)
*/
private $prnt;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Contact", mappedBy="prnt")
*/
private $children;
/**
* @ORM\Column(type="string", length=128)
*/
private $email;
/**
* @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=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 $home_address1;
/**
* @ORM\Column(type="string", length=64)
*/
private $home_address2;
/**
* @ORM\Column(type="string", length=32)
*/
private $home_city;
/**
* @ORM\Column(type="string", length=24)
*/
private $home_state;
/**
* @ORM\Column(type="string", length=10)
*/
private $home_zip;
/**
* @ORM\Column(type="string", length=48)
*/
private $home_country;
/**
* @ORM\Column(type="string", length=64)
*/
private $website;
/**
* @ORM\Column(type="datetime")
*/
private $birthday;
/**
* @ORM\Column(type="string", length=255)
*/
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="datetime")
*/
private $created_at;
/**
* @ORM\OneToMany(targetEntity="App\Entity\ContactNote", mappedBy="contact", cascade={"persist"})
*/
private $contactNotes;
/**
* @ORM\OneToMany(targetEntity="App\Entity\Lead", mappedBy="contact", cascade={"persist"})
* @ORM\OrderBy({"id" = "DESC"})
*/
private $leads;
/**
* @ORM\OneToMany(targetEntity="App\Entity\User", mappedBy="contact", cascade={"persist"})
* @ORM\OrderBy({"id" = "DESC"})
*/
private $users;
/**
* @ORM\Column(type="string", length=64)
*/
private $preferred_language;
/**
* @ORM\Column(type="boolean")
*/
private $do_not_email;
/**
* @ORM\Column(type="boolean")
*/
private $rclub_interest;
/**
* @ORM\Column(type="integer")
*/
private $status;
/**
* @ORM\Column(type="string", length=64)
*/
private $prospect;
/**
* @ORM\Column(type="string", length=255)
*/
private $roofing_materials;
/**
* @ORM\Column(type="text")
*/
private $creation_info;
public function __construct()
{
$this->email = "";
$this->firstname = "";
$this->lastname = "";
$this->company = "";
$this->job_title = "";
$this->phone_business = "";
$this->phone_mobile = "";
$this->address1 = "";
$this->address2 = "";
$this->city = "";
$this->state = "";
$this->zip = "";
$this->last4 = "";
$this->country = "";
$this->home_address1 = "";
$this->home_address2 = "";
$this->home_city = "";
$this->home_state = "";
$this->home_zip = "";
$this->home_country = "";
$this->website = "";
$this->birthday = null;
$this->type_business = "";
$this->type_work = "";
$this->year_established = new \DateTime();
$this->employee_size = 0;
$this->gender = "";
$this->ethnicity = "";
$this->language = "";
$this->preferred_language = "";
$this->sales_volume = 0;
$this->contractor_specialty = "";
$this->products_services_specialty = "";
$this->created_at = new \DateTime();
$this->leads = new ArrayCollection();
$this->users = new ArrayCollection();
$this->do_not_email = 0;
$this->rclub_interest = 0;
$this->status = SELF::STATUS_ACTIVE;
$this->prospect = "";
$this->creation_info = "";
$this->roofing_materials = "";
$this->children = new ArrayCollection();
$this->contactNotes = new ArrayCollection();
}
public function getId()
{
return $this->id;
}
public function getPrnt(): ?self
{
return $this->prnt;
}
public function setPrnt(?self $prnt): self
{
$this->prnt = $prnt;
return $this;
}
public function getChildren ()
{
return $this->children;
}
public function addChild (Contact $child) {
if (!$this->children->contains($child)) {
$this->children[] = $child;
$child->setPrnt($this);
}
return $this;
}
public function removeChild (Contact $child): self
{
if ($this->children->contains($child)) {
$this->children->removeElement($child);
// set the owning side to null (unless already changed)
if ($child->getPrnt() === $this) {
$child->setPrnt(null);
}
}
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 getFirstname(): ?string
{
return $this->firstname;
}
public function setFirstname(string $firstname = null): self
{
if (is_null($firstname)) {
$firstname = "";
}
$this->firstname = ucwords(strtolower($firstname)); //capitalize each word per ticket #89708
return $this;
}
public function getLastname(): ?string
{
return $this->lastname;
}
public function setLastname(string $lastname = null): self
{
if (is_null($lastname)) {
$lastname = "";
}
$this->lastname = ucwords(strtolower($lastname));
return $this;
}
public function getCompany(): ?string
{
return $this->company;
}
public function setCompany(string $company = null): self
{
if (is_null($company)) {
$company = "";
}
$this->company = ucwords(strtolower($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 = ucwords(strtolower($job_title));
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 = ucwords(strtolower($address1));
return $this;
}
public function getAddress2(): ?string
{
return $this->address2;
}
public function setAddress2(string $address2 = null): self
{
if (is_null($address2)) {
$address2 = "";
}
$this->address2 = ucwords(strtolower($address2));
return $this;
}
public function getCity(): ?string
{
return $this->city;
}
public function setCity(string $city = null): self
{
if (is_null($city)) {
$city = "";
}
$this->city = ucwords(strtolower($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 static function getListOfStates() {
return SELF::LIST_OF_STATES;
}
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 getHomeAddress1(): ?string
{
return $this->home_address1;
}
public function setHomeAddress1(string $home_address1 = null): self
{
if (is_null($home_address1)) {
$home_address1 = "";
}
$this->home_address1 = ucwords(strtolower($home_address1));
return $this;
}
public function getHomeAddress2(): ?string
{
return $this->home_address2;
}
public function setHomeAddress2(string $home_address2 = null): self
{
if (is_null($home_address2)) {
$home_address2 = "";
}
$this->home_address2 = ucwords(strtolower($home_address2));
return $this;
}
public function getHomeCity(): ?string
{
return $this->home_city;
}
public function setHomeCity(string $home_city = null): self
{
if (is_null($home_city)) {
$home_city = "";
}
$this->home_city = ucwords(strtolower($home_city));
return $this;
}
public function getHomeState(): ?string
{
return $this->home_state;
}
public function setHomeState(string $home_state = ""): self
{
if (is_null($home_state)) {
$home_state = "";
}
$this->home_state = $home_state;
return $this;
}
public function getHomeZip(): ?string
{
return $this->home_zip;
}
public function setHomeZip(string $home_zip = null): self
{
if (is_null($home_zip)) {
$home_zip = "";
}
$this->home_zip = $home_zip;
return $this;
}
public function getHomeCountry(): ?string
{
return $this->home_country;
}
public function setHomeCountry(string $home_country = null): self
{
if (is_null($home_country)) {
$home_country = "";
}
$this->home_country = $home_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 getBirthday(): ?\DateTimeInterface
{
return $this->birthday;
}
public function setBirthday(\DateTimeInterface $birthday = null): self
{
$this->birthday = $birthday;
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 typeBusinessContains($type)
{
$arr = explode(",", $this->type_business);
return in_array($type, $arr);
}
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 getPreferredLanguage(): string
{
return $this->preferred_language;
}
public function setPreferredLanguage(string $preferred_language = null): self
{
if (is_null($preferred_language)) {
$preferred_language = "";
}
$this->preferred_language = $preferred_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 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;
}
/**
* @return Collection|Lead[]
*/
public function getLeads(): Collection
{
return $this->leads;
}
public function addLead(Lead $lead): self
{
if (!$this->leads->contains($lead)) {
$this->leads[] = $lead;
$lead->setContact($this);
}
return $this;
}
public function removeLead(Lead $lead): self
{
if ($this->leads->contains($lead)) {
$this->leads->removeElement($lead);
// set the owning side to null (unless already changed)
if ($lead->setContact() === $this) {
$lead->setContact(null);
}
}
return $this;
}
/**
* @return Collection|User[]
*/
public function getUsers(): Collection
{
return $this->users;
}
public function addUser(User $user): self
{
if (!$this->users->contains($user)) {
$this->users[] = $user;
$user->setContact($this);
}
return $this;
}
public function removeUser(User $user): self
{
if ($this->users->contains($user)) {
$this->users->removeElement($user);
// set the owning side to null (unless already changed)
if ($user->setContact() === $this) {
$user->setContact(null);
}
}
return $this;
}
public function getDoNotEmail(): ?bool
{
return $this->do_not_email == 1;
}
public function setDoNotEmail(bool $do_not_email): self
{
$this->do_not_email = $do_not_email ? 1 : 0;
return $this;
}
public function getRclubInterest(): ?bool
{
return $this->rclub_interest == 1;
}
public function setRclubInterest(bool $rclub_interest): self
{
$this->rclub_interest = $rclub_interest ? 1 : 0;
return $this;
}
public function getStatus(): ?int
{
return $this->status;
}
public function setStatus(int $status): self
{
$this->status = $status;
return $this;
}
public function getProspect(): string
{
return $this->prospect;
}
public function setProspect(string $prospect = null): self
{
if (is_null($prospect)) {
$prospect = "";
}
$this->prospect = $prospect;
return $this;
}
public function getRoofingMaterials(): ?string
{
return $this->roofing_materials;
}
public function setRoofingMaterials(string $roofing_materials = ""): self
{
if (is_null($roofing_materials)) {
$roofing_materials = "";
}
$this->roofing_materials = $roofing_materials;
return $this;
}
public function roofingMaterialsContains($material)
{
$arr = explode(",", $this->roofing_materials);
return in_array($material, $arr);
}
public function getCreationInfo(): string
{
return $this->creation_info;
}
public function setCreationInfo(string $creation_info = null): self
{
$this->creation_info = $creation_info ? $creation_info : "";
return $this;
}
public function getContactNotes()
{
return $this->contactNotes;
}
public function getContactNotesText()
{
$notes = $this->contactNotes;
$return = [];
foreach($notes as $note) {
$return[] = "\"" . $note->getDescription() . "\" " . $note->getByLine();
}
return implode(" - ", $return);
}
public function addContactNote(ContactNote $contactNote): self
{
if (!$this->contactNotes->contains($contactNote)) {
$this->contactNotes[] = $contactNote;
$contactNote->setContact($this);
}
return $this;
}
public function removeContactNote(ContactNote $contactNote): self
{
if ($this->contactNotes->contains($contactNote)) {
$this->contactNotes->removeElement($contactNote);
// set the owning side to null (unless already changed)
if ($contactNote->getContact() === $this) {
$contactNote->getContact(null);
}
}
return $this;
}
public function __toString ()
{
if($this->firstname) {
$return = $this->firstname;
if($this->lastname)
{
$return .= " " . $this->lastname;
}
return $return;
}
return $this->email ? $this->email : '';
}
}