* Timesheet: filtering by a status did not contain timesheets of sub-status

This commit is contained in:
Ralf Becker 2012-07-03 10:31:22 +00:00
parent 3459a34a9f
commit b89ac80f6b

View File

@ -217,6 +217,27 @@ class timesheet_bo extends so_sql_cf
$this->status_labels_config = $sorted;
}
/**
* Return evtl. existing sub-statuses of given status
*
* @param int $status
* @return array|int with sub-statuses incl. $status or just $status
*/
function get_sub_status($status)
{
if (!isset($this->status_labels_config)) $this->load_statuses();
$stati = array($status);
foreach($this->status_labels_config as $stat)
{
if ($stat['parent'] && in_array($stat['parent'], $stati))
{
$stati[] = $stat['id'];
}
}
//error_log(__METHOD__."($status) returning ".array2string(count($stati) == 1 ? $status : $stati));
return count($stati) == 1 ? $status : $stati;
}
/**
* Make nice labels with leading spaces depending on depth
*
@ -459,6 +480,10 @@ class timesheet_bo extends so_sql_cf
}
}
}
if (isset($filter['ts_status']) && $filter['ts_status'])
{
$filter['ts_status'] = $this->get_sub_status($filter['ts_status']);
}
if (!count($filter['ts_owner']))
{
$this->total = 0;