Ejemplo n.º 1
0
 static function getFields()
 {
     return SearchFields_ContactOrg::getFields();
 }
Ejemplo n.º 2
0
 private function _getListAction($path)
 {
     @($p_page = DevblocksPlatform::importGPC($_REQUEST['p'], 'integer', 0));
     list($orgs, $null) = DAO_ContactOrg::search(array(), array(), 50, $p_page, SearchFields_ContactOrg::NAME, true, false);
     $this->_renderResults($orgs, SearchFields_ContactOrg::getFields(), 'org', 'orgs');
 }
Ejemplo n.º 3
0
 /**
  * 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_ContactOrg::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
     $total = -1;
     $select_sql = sprintf("SELECT " . "c.id as %s, " . "c.name as %s, " . "c.street as %s, " . "c.city as %s, " . "c.province as %s, " . "c.postal as %s, " . "c.country as %s, " . "c.phone as %s, " . "c.website as %s, " . "c.created as %s ", SearchFields_ContactOrg::ID, SearchFields_ContactOrg::NAME, SearchFields_ContactOrg::STREET, SearchFields_ContactOrg::CITY, SearchFields_ContactOrg::PROVINCE, SearchFields_ContactOrg::POSTAL, SearchFields_ContactOrg::COUNTRY, SearchFields_ContactOrg::PHONE, SearchFields_ContactOrg::WEBSITE, SearchFields_ContactOrg::CREATED);
     $join_sql = 'FROM contact_org c ';
     // Custom field joins
     list($select_sql, $join_sql, $has_multiple_values) = self::_appendSelectJoinSqlForCustomFieldTables($tables, $params, 'c.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 c.id ' : '') . $sort_sql;
     // [TODO] Could push the select logic down a level too
     if ($limit > 0) {
         $rs = $db->SelectLimit($sql, $limit, $start) or die(__CLASS__ . '(' . __LINE__ . ')' . ':' . $db->ErrorMsg());
         /* @var $rs ADORecordSet */
     } else {
         $rs = $db->Execute($sql) or die(__CLASS__ . '(' . __LINE__ . ')' . ':' . $db->ErrorMsg());
         /* @var $rs ADORecordSet */
         $total = $rs->RecordCount();
     }
     $results = array();
     if (is_a($rs, 'ADORecordSet')) {
         while (!$rs->EOF) {
             $result = array();
             foreach ($rs->fields as $f => $v) {
                 $result[$f] = $v;
             }
             $ticket_id = intval($rs->fields[SearchFields_ContactOrg::ID]);
             $results[$ticket_id] = $result;
             $rs->MoveNext();
         }
     }
     // [JAS]: Count all
     if ($withCounts) {
         $count_sql = ($has_multiple_values ? "SELECT COUNT(DISTINCT c.id) " : "SELECT COUNT(c.id) ") . $join_sql . $where_sql;
         $total = $db->GetOne($count_sql);
     }
     return array($results, $total);
 }