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