Created
November 30, 2015 11:54
-
-
Save allyjweir/b1fa21052f37611f4f76 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace Heart; | |
use Doctrine\ORM\Mapping as ORM; | |
/** | |
* Contact | |
* | |
* @ORM\Table(name="simulate_heart.Contact", uniqueConstraints={@ORM\UniqueConstraint(name="Email", columns={"Email"})}, indexes={@ORM\Index(name="OrgID", columns={"OrgID"}), @ORM\Index(name="ContactTypeID", columns={"ContactTypeID"}), @ORM\Index(name="OrgSiteID", columns={"OrgSiteID"}), @ORM\Index(name="PiwikID", columns={"PiwikID"}), @ORM\Index(name="ContactTypeID_2", columns={"ContactTypeID"})}) | |
* @ORM\Entity | |
*/ | |
class Contact | |
{ | |
/** | |
* @ORM\Column(name="ContactID", type="integer", nullable=false) | |
* @ORM\Id | |
* @ORM\GeneratedValue(strategy="IDENTITY") | |
*/ | |
private $id; | |
/** | |
* @ORM\Column(name="FirstName", type="string", length=30, nullable=false) | |
*/ | |
private $firstName = ''; | |
/** | |
* @ORM\Column(name="LastName", type="string", length=30, nullable=false) | |
*/ | |
private $lastName = ''; | |
/** | |
* @ORM\Column(name="Email", type="string", length=50, nullable=false) | |
*/ | |
private $email = ''; | |
/** | |
* @ORM\Column(name="Phone", type="string", length=20, nullable=false) | |
*/ | |
private $phone = ''; | |
/** | |
* @ORM\Column(name="JobTitle", type="string", length=50, nullable=false) | |
*/ | |
private $jobTitle = ''; | |
/** | |
* @ORM\Column(name="PiwikID", type="binary", nullable=false) | |
*/ | |
private $piwikId = 0; | |
/** | |
* @ORM\Column(name="Valid", type="boolean") | |
*/ | |
private $valid = 0; | |
/** | |
* @ORM\Column(name="SuppressionStatus", type="boolean") | |
* 1 for suppressed (we do not email LN) | |
* 0 for not suppressed (we can email LN) | |
*/ | |
private $suppressionStatus = 0; | |
/** | |
* @ORM\Column(name="DoNotContactAgainStatus", type="boolean") | |
* 1 for do not contact | |
* 0 for do not contact | |
*/ | |
private $contactStatus = 0; | |
/** | |
* @ORM\Column(name="ModifiedTime", type="datetime") | |
*/ | |
private $lastModified; | |
/**************************************************************************/ | |
/** | |
* @ORM\ManyToOne(targetEntity="Heart\Organisation", inversedBy="employees") | |
* @ORM\JoinColumn(name="OrgID", referencedColumnName="OrgID") | |
*/ | |
public $organisation; | |
/** | |
* @ORM\ManyToOne(targetEntity="Heart\OrganisationSite", inversedBy="contacts") | |
* @ORM\JoinColumn(name="OrgSiteID", referencedColumnName="OrgSiteID") | |
*/ | |
public $organisationSite; | |
/** | |
* @ORM\ManyToOne(targetEntity="Heart\ContactType") | |
* @ORM\JoinColumn(name="ContactTypeID", referencedColumnName="ContactTypeID") | |
*/ | |
private $contactType; | |
/**************************************************************************/ | |
/** | |
* @var \Heart\Contacts\ContactMetadata | |
* | |
* @ORM\OneToMany(targetEntity="Heart\Contacts\ContactMetadata", mappedBy="contact") | |
*/ | |
private $metadata; | |
/** | |
* @var \LeadNurturing\FlowExecution | |
* | |
* @ORM\OneToMany(targetEntity="LeadNurturing\FlowExecution", mappedBy="contact") | |
* @ORM\JoinColumn(name="ContactID", referencedColumnName="contact_id") | |
*/ | |
private $leadNurturingSubscriptions; | |
/** | |
* @var \AnnualMaintenance\Subscription | |
* | |
* @ORM\OneToMany(targetEntity="AnnualMaintenance\Subscription", mappedBy="contact") | |
* @ORM\JoinColumn(name="ContactID", referencedColumnName="contact_id") | |
*/ | |
private $amSubscriptions; | |
/**************************************************************************/ | |
public function getId() { return $this->id; } | |
public function getFirstName() { return $this->firstName; } | |
public function getLastName() { return $this->lastName; } | |
public function getEmail() { return $this->email; } | |
public function getPhone() { return $this->phone; } | |
public function getJobTitle() { return $this->jobTitle; } | |
public function getPiwikId() { return $this->piwikId; } | |
public function getOrganisation() { return $this->organisation; } | |
public function getOrganisationSite() { return $this->organisationSite; } | |
public function getContactType() { return $this->contactType; } | |
public function getMetadata() { return $this->metadata; } | |
/** | |
* Returns boolean value if contact is to be suppressed or not. | |
* | |
* | |
* @return boolean | |
*/ | |
public function getSuppressionStatus() { | |
if ($this->suppressionStatus == 1) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
/** | |
* Returns a boolean value if contact is should ever be contacted | |
* at all or not. | |
* | |
* Some individuals request that we never contact them again. This | |
* is the way that this is kept track of. | |
* | |
* @return boolean | |
*/ | |
public function getContactStatus() { | |
if ($this->contactStatus == 1) { | |
return true; | |
} else { | |
return false; | |
} | |
} | |
/**************************************************************************/ | |
public function setFirstName($firstName) { $this->firstName = $firstName; } | |
public function setLastName($lastName) { $this->lastName = $lastName; } | |
public function setEmail($email) { $this->email = $email; } | |
public function setPhone($phone) { $this->phone = $phone; } | |
public function setJobTitle($jobTitle) { $this->jobTitle = $jobTitle; } | |
public function setPiwikId($piwikId) { $this->piwikId = $piwikId; } | |
public function setOrganisation($organisation) { $this->organisation = $organisation; } | |
public function setOrganisationSite($organisationSite) { $this->organisationSite = $organisationSite; } | |
public function setContactType($contactType) { $this->contactType = $contactType; } | |
public function setSuppressionStatus($suppressionStatus) { $this->suppressionStatus = $suppressionStatus; } | |
public function setContactStatus($contactStatus) { $this->contactStatus = $contactStatus; } | |
/**************************************************************************/ | |
public function __construct() { | |
$this->metadata = new \Doctrine\Common\Collections\ArrayCollection(); | |
} | |
/**************************************************************************/ | |
public function toJsonArray() { | |
$jsonArray = array( | |
'id' => $this->getId(), | |
'email' => utf8_encode($this->getEmail()), | |
'firstName' => utf8_encode($this->getFirstName()), | |
'lastName' => utf8_encode($this->getLastName()), | |
'phone' => utf8_encode($this->getPhone()), | |
'jobTitle' => utf8_encode($this->getJobTitle()), | |
'suppressionStatus' => utf8_encode($this->getSuppressionStatus()), | |
); | |
if ($this->getOrganisation()) { | |
$jsonArray['organisation'] = $this->getOrganisation()->toJsonArray(); | |
} | |
if ($this->getOrganisationSite()) { | |
$jsonArray['organisationSite'] = $this->getOrganisationSite()->toJsonArray(); | |
} | |
return $jsonArray; | |
} | |
/**************************************************************************/ | |
public static function getReference($id) { | |
return get_instance()->doctrine->getManager()->getReference('Heart\Contact', $id); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment