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

This commit is contained in:
Ralf Becker 2012-07-03 10:32:27 +00:00
parent 67379b1104
commit b886ffb6c8

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;