From b89ac80f6bb2aef0e3ccf05cbe869341f810e483 Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Tue, 3 Jul 2012 10:31:22 +0000 Subject: [PATCH] * Timesheet: filtering by a status did not contain timesheets of sub-status --- timesheet/inc/class.timesheet_bo.inc.php | 25 ++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/timesheet/inc/class.timesheet_bo.inc.php b/timesheet/inc/class.timesheet_bo.inc.php index f3b3583f9e..24954a7eb4 100644 --- a/timesheet/inc/class.timesheet_bo.inc.php +++ b/timesheet/inc/class.timesheet_bo.inc.php @@ -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;