You are here

function _casetracker_dashboard_projectCasesCount in Case Tracker 5

Function to get an array of projects, case status count

Parameters

void:

Return value

array

1 call to _casetracker_dashboard_projectCasesCount()
_casetracker_dashboard_states in ./casetracker_dashboard.module
Function to get an overview of all projects and their states count

File

./casetracker_dashboard.module, line 269

Code

function _casetracker_dashboard_projectCasesCount() {
  $filter_args = array_filter(variable_get('casetracker_project_node_types', array(
    'casetracker_basic_project',
  )));
  $sql = db_rewrite_sql('SELECT ' . ' n.nid, c.csid, Count(1) AS number_of_cases ' . 'FROM ' . ' {node} AS n ' . ' Inner Join {casetracker_case} AS b ON (n.nid = b.pid) ' . ' Inner Join {node} AS d ON (b.vid = d.vid)' . ' Inner Join {casetracker_case_states} AS c ON (b.case_status_id = c.csid) ' . 'WHERE ' . ' n.type IN (\'' . implode('\',\'', $filter_args) . '\') ' . ' AND n.status = 1 ');
  $sql .= 'GROUP BY n.nid, c.csid ';
  $sql .= 'ORDER BY n.nid ASC, c.csid ASC ';
  $results = db_query($sql);
  $caseCounter = array();
  while ($row = db_fetch_object($results)) {
    $caseCounter[] = $row;
  }
  return $caseCounter;
}