/** * Lists timeslices as timeobjects. * * @param array $time_categories The time categories (from * listTimeObjectCategories) to list. * @param mixed $start The start date of the period. * @param mixed $end The end date of the period. * * @return array An array of timeObject results. * @throws Hermes_Exception */ public function listTimeObjects($time_categories, $start, $end) { $objects = array(); foreach ($time_categories as $category) { $params = array('start' => $start->timestamp(), 'end' => $end->timestamp(), 'submitted' => intval($category == 'submitted'), 'employee' => $GLOBALS['registry']->getAuth()); $slices = $GLOBALS['injector']->getInstance('Hermes_Driver')->getHours($params); foreach ($slices as $slice) { $cn = current($GLOBALS['registry']->clients->getClients(array($slice['client']))); $co = $slice['_costobject_name']; $tobj = array($slice['id'] => array('title' => sprintf(_("%.2f hours: %s"), $slice['hours'], empty($cn['name']) ? empty($co) ? $slice['description'] : $co : $cn['name']), 'description' => $slice->toString(), 'link' => $category == 'submitted' ? false : Hermes::url('entry', array('id' => $slice['id'])), 'start' => date('Y-m-d\\TH:i:s', $slice['date']->timestamp()), 'end' => date('Y-m-d\\TH:i:s', $slice['date']->timestamp() + $slice['hours'] * 3600))); $objects = array_merge($objects, $tobj); } } return $objects; }