2013-11-26 13:45:07 +01:00
|
|
|
<?php
|
|
|
|
|
2013-12-04 17:20:14 +01:00
|
|
|
class Contact extends EntityModel
|
2013-11-26 13:45:07 +01:00
|
|
|
{
|
2015-01-11 13:30:08 +01:00
|
|
|
public static $fieldFirstName = 'Contact - First Name';
|
|
|
|
public static $fieldLastName = 'Contact - Last Name';
|
|
|
|
public static $fieldEmail = 'Contact - Email';
|
|
|
|
public static $fieldPhone = 'Contact - Phone';
|
2013-11-26 13:45:07 +01:00
|
|
|
|
2015-01-11 13:30:08 +01:00
|
|
|
public function client()
|
|
|
|
{
|
|
|
|
return $this->belongsTo('Client');
|
|
|
|
}
|
2013-11-26 13:45:07 +01:00
|
|
|
|
2015-01-11 13:30:08 +01:00
|
|
|
public function getPersonType()
|
|
|
|
{
|
|
|
|
return PERSON_CONTACT;
|
|
|
|
}
|
2013-12-01 21:58:25 +01:00
|
|
|
|
2015-01-11 13:30:08 +01:00
|
|
|
/*
|
|
|
|
public function getLastLogin()
|
|
|
|
{
|
|
|
|
if ($this->last_login == '0000-00-00 00:00:00')
|
|
|
|
{
|
|
|
|
return '---';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return $this->last_login->format('m/d/y h:i a');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
2013-12-30 21:17:45 +01:00
|
|
|
|
2015-01-11 13:30:08 +01:00
|
|
|
public function getDisplayName()
|
|
|
|
{
|
|
|
|
if ($this->getFullName()) {
|
|
|
|
return $this->getFullName();
|
|
|
|
} else {
|
|
|
|
return $this->email;
|
|
|
|
}
|
|
|
|
}
|
2014-01-02 18:16:00 +01:00
|
|
|
|
2015-01-11 13:30:08 +01:00
|
|
|
public function getFullName()
|
|
|
|
{
|
|
|
|
if ($this->first_name || $this->last_name) {
|
|
|
|
return $this->first_name.' '.$this->last_name;
|
|
|
|
} else {
|
|
|
|
return '';
|
|
|
|
}
|
|
|
|
}
|
2013-11-29 13:09:21 +01:00
|
|
|
|
2015-01-11 13:30:08 +01:00
|
|
|
public function getDetails()
|
|
|
|
{
|
|
|
|
$str = '';
|
2013-11-29 13:09:21 +01:00
|
|
|
|
2015-01-11 13:30:08 +01:00
|
|
|
if ($this->first_name || $this->last_name) {
|
|
|
|
$str .= '<b>'.$this->first_name.' '.$this->last_name.'</b><br/>';
|
|
|
|
}
|
2013-11-29 13:09:21 +01:00
|
|
|
|
2015-01-11 13:30:08 +01:00
|
|
|
if ($this->email) {
|
|
|
|
$str .= '<i class="fa fa-envelope" style="width: 20px"></i>'.HTML::mailto($this->email, $this->email).'<br/>';
|
|
|
|
}
|
2013-11-29 13:09:21 +01:00
|
|
|
|
2015-01-11 13:30:08 +01:00
|
|
|
if ($this->phone) {
|
|
|
|
$str .= '<i class="fa fa-phone" style="width: 20px"></i>'.Utils::formatPhoneNumber($this->phone);
|
|
|
|
}
|
2013-11-29 13:09:21 +01:00
|
|
|
|
2015-01-11 13:30:08 +01:00
|
|
|
if ($str) {
|
|
|
|
$str = '<p>'.$str.'</p>';
|
|
|
|
}
|
|
|
|
|
|
|
|
return $str;
|
|
|
|
}
|
|
|
|
}
|