/** getEmailList @return List of Email Addresses and Names from Contact and All Sub Contacts */ function getEmailList() { $db = Zend_Registry::get('db'); $list = array(); $sql = "select id,email,contact from contact where (id={$this->id}) or (parent_id={$this->id})"; $co_list = $db->fetchAll($sql); foreach ($co_list as $x) { $co = new Contact($x); if (strlen($co->email)) { $list[$co->email] = $co->contact . '(' . $co->email . ')'; } $ch_list = $co->getChannelList(); foreach ($ch_list as $ch) { if ($ch->kind == ContactChannel::EMAIL) { $list[$ch->data] = $co->contact . '(' . $ch->data . ')'; } } } return $list; }
/** */ namespace Edoceo\Imperium; use Edoceo\Radix\DB\SQL; if (empty($_GET['c'])) { return 0; } $c = new Contact(intval($_GET['c'])); if (empty($c['id'])) { Session::flash('fail', 'Contact not found'); // Radix::redirect('/contact'); } $_ENV['contact'] = $c; $this->Contact = $c; // Why Pointing this way? $this->Account = $c->getAccount(); $this->ContactList = array(); if (empty($c->parent_id)) { // $this->ContactList = SQL::fetch_all("SELECT * FROM contact WHERE id != ? AND (parent_id = ? OR company = ?)",array($c->id,$c->id,$c->company)); $this->ContactList = SQL::fetch_all('SELECT * FROM contact WHERE id != ? AND parent_id = ?', array($c->id, $c->id)); } $this->ContactAddressList = $c->getAddressList(); $this->ContactChannelList = $c->getChannelList(); $this->ContactNoteList = $c->getNotes(); $this->ContactFileList = $c->getFiles(); // @note what does order by star, status do? Join base_enum? $this->WorkOrderList = SQL::fetch_all('SELECT workorder.*, contact.name AS contact_name FROM workorder JOIN contact ON workorder.contact_id = contact.id WHERE workorder.contact_id = ? ORDER BY workorder.date DESC, workorder.id DESC', array($c['id'])); $this->InvoiceList = SQL::fetch_all('SELECT * FROM invoice WHERE contact_id = ? ORDER BY date DESC, id DESC', array($c['id'])); $_ENV['title'] = array($this->Contact['kind'], sprintf('#%d:%s', $this->Contact['id'], $this->Contact['name']));