function showTabTasksAction() { $translate = DevblocksPlatform::getTranslationService(); @($org = DevblocksPlatform::importGPC($_REQUEST['org'])); $tpl = DevblocksPlatform::getTemplateService(); $tpl->assign('path', $this->_TPL_PATH); $contact = DAO_ContactOrg::get($org); $tpl->assign('contact', $contact); $defaults = new C4_AbstractViewModel(); $defaults->class_name = 'C4_TaskView'; $defaults->id = 'org_tasks'; $defaults->view_columns = array(SearchFields_Task::SOURCE_EXTENSION, SearchFields_Task::DUE_DATE, SearchFields_Task::WORKER_ID, SearchFields_Task::COMPLETED_DATE); $view = C4_AbstractViewLoader::getView('org_tasks', $defaults); $view->name = $translate->_('common.tasks') . ' ' . $contact->name; $view->params = array(new DevblocksSearchCriteria(SearchFields_Task::SOURCE_EXTENSION, '=', 'cerberusweb.tasks.org'), new DevblocksSearchCriteria(SearchFields_Task::SOURCE_ID, '=', $org)); $tpl->assign('view', $view); C4_AbstractViewLoader::setView($view->id, $view); $tpl->assign('contacts_page', 'orgs'); $tpl->assign('search_columns', SearchFields_Address::getFields()); $tpl->display('file:' . $this->_TPL_PATH . 'contacts/orgs/tabs/tasks.tpl'); exit; }
static function getFields() { return SearchFields_Address::getFields(); }
private function _getListAction($path) { $xml = new SimpleXMLElement("<addresses></addresses>"); @($p_page = DevblocksPlatform::importGPC($_REQUEST['p'], 'integer', 0)); list($addresses, $null) = DAO_Address::search(array(), array(), 50, $p_page, SearchFields_Address::EMAIL, true, false); $this->_renderResults($addresses, SearchFields_Address::getFields(), 'address', 'addresses'); }
/** * Enter description here... * * @param DevblocksSearchCriteria[] $params * @param integer $limit * @param integer $page * @param string $sortBy * @param boolean $sortAsc * @param boolean $withCounts * @return array */ static function search($columns, $params, $limit = 10, $page = 0, $sortBy = null, $sortAsc = null, $withCounts = true) { $db = DevblocksPlatform::getDatabaseService(); $fields = SearchFields_Address::getFields(); // Sanitize if (!isset($fields[$sortBy])) { $sortBy = null; } list($tables, $wheres) = parent::_parseSearchParams($params, $columns, $fields, $sortBy); $start = $page * $limit; // [JAS]: 1-based [TODO] clean up + document $select_sql = sprintf("SELECT " . "a.id as %s, " . "a.email as %s, " . "a.first_name as %s, " . "a.last_name as %s, " . "a.contact_org_id as %s, " . "o.name as %s, " . "a.num_spam as %s, " . "a.num_nonspam as %s, " . "a.is_banned as %s ", SearchFields_Address::ID, SearchFields_Address::EMAIL, SearchFields_Address::FIRST_NAME, SearchFields_Address::LAST_NAME, SearchFields_Address::CONTACT_ORG_ID, SearchFields_Address::ORG_NAME, SearchFields_Address::NUM_SPAM, SearchFields_Address::NUM_NONSPAM, SearchFields_Address::IS_BANNED); $join_sql = "FROM address a " . "LEFT JOIN contact_org o ON (o.id=a.contact_org_id) "; // [JAS]: Dynamic table joins // (isset($tables['o']) ? "LEFT JOIN contact_org o ON (o.id=a.contact_org_id)" : " "). // (isset($tables['mc']) ? "INNER JOIN message_content mc ON (mc.message_id=m.id)" : " "). // Custom field joins list($select_sql, $join_sql, $has_multiple_values) = self::_appendSelectJoinSqlForCustomFieldTables($tables, $params, 'a.id', $select_sql, $join_sql); $where_sql = "" . (!empty($wheres) ? sprintf("WHERE %s ", implode(' AND ', $wheres)) : ""); $sort_sql = !empty($sortBy) ? sprintf("ORDER BY %s %s ", $sortBy, $sortAsc || is_null($sortAsc) ? "ASC" : "DESC") : " "; $sql = $select_sql . $join_sql . $where_sql . ($has_multiple_values ? 'GROUP BY a.id ' : '') . $sort_sql; $rs = $db->SelectLimit($sql, $limit, $start) or die(__CLASS__ . '(' . __LINE__ . ')' . ':' . $db->ErrorMsg()); /* @var $rs ADORecordSet */ $results = array(); if (is_a($rs, 'ADORecordSet')) { while (!$rs->EOF) { $result = array(); foreach ($rs->fields as $f => $v) { $result[$f] = $v; } $id = intval($rs->fields[SearchFields_Address::ID]); $results[$id] = $result; $rs->MoveNext(); } } // [JAS]: Count all $total = -1; if ($withCounts) { $count_sql = ($has_multiple_values ? "SELECT COUNT(DISTINCT a.id) " : "SELECT COUNT(a.id) ") . $join_sql . $where_sql; $total = $db->GetOne($count_sql); } return array($results, $total); }