/** 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; }
<?php /** @file @brief Save a Contact */ namespace Edoceo\Imperium; use Edoceo\Radix; use Edoceo\Radix\Session; use Edoceo\Radix\DB\SQL; use Edoceo\Imperium\Contact\Event; $C = new Contact($_GET['c']); // Delete Requested? switch (strtolower($_POST['a'])) { case 'capture': Radix::redirect('/contact/capture?c=' . $c['id']); break; case 'create-account': $a = new Account(); $a['kind'] = 'Sub: Customer'; $a['code'] = $id; $a['name'] = $C['name']; $a['parent_id'] = $_ENV['account']['contact_ledger_container_id']; $a['active'] = 't'; $a['link_to'] = 'contact'; $a['link_id'] = $id; $a->save(); $C['account_id'] = $a['id']; $C->save(); Session::flash('fail', SQL::lastError());
<?php /** */ 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']));
<?php /** @file @brief Save a Contact */ namespace Edoceo\Imperium; use Edoceo\Radix; use Edoceo\Radix\Session; use Edoceo\Radix\DB\SQL; use Edoceo\Imperium\Contact\Event; $c = new Contact($_GET['c']); // Delete Requested? switch (strtolower($_POST['a'])) { case 'capture': Radix::redirect('/contact/capture?c=' . $c['id']); break; case 'create-account': $a = new Account(); $a['kind'] = 'Sub: Customer'; $a['code'] = $id; $a['name'] = $c['name']; $a['parent_id'] = $_ENV['account']['contact_ledger_container_id']; $a['active'] = 't'; $a['link_to'] = 'contact'; $a['link_id'] = $id; $a->save(); $c['account_id'] = $a['id']; $c->save(); Session::flash('fail', SQL::lastError());