Skip to content
Snippets Groups Projects
Commit 6548a89a authored by Jared Hancock's avatar Jared Hancock
Browse files

Handle null items of the report table better

Previously, if a SQL query did not return results for all rows, the results
that were returned would be added to the table in a new column(s) and those
(new) columns would be populated from top down. Therefore, the data would
not correcly line up with the row to which it pertains. Now, results are
matched back to the row to which they pertain, and rows are checked after
each query to ensure they all have the same number of columns.
parent 9aeabebe
No related branches found
No related tags found
No related merge requests found
......@@ -104,16 +104,27 @@ class OverviewReportAjaxAPI extends AjaxController {
ORDER BY '.$info['fields'])
);
$rows = array();
$cols = 1;
foreach ($queries as $q) {
list($c, $sql) = $q;
$res = db_query($sql);
$i = 0;
$cols += $c;
while ($row = db_fetch_row($res)) {
if (count($rows) <= $i)
$rows[] = array_slice($row, 0, count($row) - $c);
$rows[$i] = array_merge($rows[$i], array_slice($row, -$c));
$i++;
$found = false;
foreach ($rows as &$r) {
if ($r[0] == $row[0]) {
$r = array_merge($r, array_slice($row, -$c));
$found = true;
break;
}
}
if (!$found)
$rows[] = array_merge(array($row[0]), array_slice($row, -$c));
}
# Make sure each row has the same number of items
foreach ($rows as &$r)
while (count($r) < $cols)
$r[] = null;
}
return array("columns" => array_merge($info['headers'],
array('Open','Assigned','Overdue','Closed','Reopened',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment