/** * List all time total for a project (both billed and unbilled) * * @access public * @param void * @return null */ function byproject() { $this->setLayout('administration'); if (!logged_user()->isAdministrator(owner_company())) { flash_error(lang('no access permissions')); $this->redirectTo('dashboard'); } // if $project_id = (int) array_var($_GET, 'id', 0); if ($project_id < 0) { $project_id = 0; } $redirect_to = array_var($_GET, 'redirect_to'); if ($redirect_to == '') { $redirect_to = get_url('time', 'byproject', array('id' => $project_id)); $redirect_to = str_replace('&', '&', trim($redirect_to)); } // if $unbilled = ProjectTimes::getTimeByProjectStatus(Projects::findById($project_id)); $billed = ProjectTimes::getTimeByProjectStatus(Projects::findById($project_id), 1); tpl_assign('unbilled', $unbilled); tpl_assign('billed', $billed); tpl_assign('project', Projects::findById($project_id)); tpl_assign('redirect_to', $redirect_to); $this->setSidebar(get_template_path('index_sidebar', 'time')); }
/** * Return all project time * * @access public * @param void * @return array */ function getTimes() { if (!plugin_active('times')) return null; if(logged_user()->isMemberOfOwnerCompany()) return $this->getAllTimes(); // member of owner company if(is_null($this->times)) { $this->times = ProjectTimes::findAll(array( 'conditions' => array('`project_id` = ? AND `is_private` = ?', $this->getId(), 0), 'order' => 'done_date desc' )); // findAll } // if return $this->times; } // getTimes
"><?php echo clean($user->getDisplayName()); ?> </a> </td> <td class="middle"> <?php echo ProjectTimes::getTimeByUserStatus($user, 0, 'hours'); ?> <?php echo lang('hrs'); ?> </td> <td class="middle"> <?php echo ProjectTimes::getTimeByUserStatus($user, 1, 'hours'); ?> <?php echo lang('hrs'); ?> </td> </tr> <?php } // foreach ?> </table> <?php } else { echo lang('no users in company'); }
} echo '<td class="timeDetails">' . clean($tl_entry->getName()) . '</td>'; echo '<td class="timeHours">' . $tl_entry->getHours() . '</td>'; echo '</tr>'; } } if ($headers_outputted) { echo '<tr><td>' . '<strong>Total</strong>' . '</td><td></td><td></td><td><strong>' . $tt . '</strong></td></tr>'; echo '</table>'; } } } if (is_array($task_list->getTasks()) && $tl_time > 0) { foreach ($task_list->getTasks() as $task) { echo '<h4>' . $task->getText() . '</h4>'; $ts = ProjectTimes::getTimeByTask($task); if (is_array($ts)) { $tt = 0; echo '<table class="timeLogs blank"><tr><th>Date</th><th>Name</th><th>Details</th><th>Hours</th></tr>'; foreach ($ts as $t) { echo '<tr>'; echo '<td class="timeDate">' . format_descriptive_date($t->getDoneDate(), 0) . '</td>'; if ($t->getAssignedTo() instanceof ApplicationDataObject) { echo '<td class="timeUser">' . clean($t->getAssignedTo()->getObjectName()) . '</td>'; } else { echo '<td class="timeUser">' . '' . '</td>'; } echo '<td class="timeDetails">' . clean($t->getName()) . '</td>'; echo '<td class="timeHours">' . $t->getHours() . '</td>'; echo '</tr>'; $tt += $t->getHours();
"><?php echo clean($project->getName()); ?> </a> </td> <td class="middle"> <?php echo ProjectTimes::getTimeByProjectStatus($project, 0, 'hours'); ?> <?php echo lang('hrs'); ?> </td> <td class="middle"> <?php echo ProjectTimes::getTimeByProjectStatus($project, 1, 'hours'); ?> <?php echo lang('hrs'); ?> </td> </tr> <?php } // foreach ?> </table> <?php } else { echo lang('no projects owned by company'); }
/** * This function will return paginated result. Result is an array where first element is * array of returned object and second populated pagination object that can be used for * obtaining and rendering pagination data using various helpers. * * Items and pagination array vars are indexed with 0 for items and 1 for pagination * because you can't use associative indexing with list() construct * * @access public * @param array $arguments Query argumens (@see find()) Limit and offset are ignored! * @param integer $items_per_page Number of items per page * @param integer $current_page Current page number * @return array */ function paginate($arguments = null, $items_per_page = 10, $current_page = 1) { if (isset($this) && instance_of($this, 'ProjectTimes')) { return parent::paginate($arguments, $items_per_page, $current_page); } else { return ProjectTimes::instance()->paginate($arguments, $items_per_page, $current_page); //$instance =& ProjectTimes::instance(); //return $instance->paginate($arguments, $items_per_page, $current_page); } // if }
/** * Display time management tool * * @access public * @param void * @return null */ function time() { if (plugin_active('time')) { tpl_assign('projects', logged_user()->getProjects()); tpl_assign('users', owner_company()->getUsers()); $status = array_var($_GET, 'status') ? array_var($_GET, 'status') : 0; $times = ProjectTimes::getTimeByStatus($status); $redirect_to = array_var($_GET, 'redirect_to'); if ($redirect_to == '') { $redirect_to = get_url('administration', 'time', array('status' => $status)); $redirect_to = str_replace('&', '&', trim($redirect_to)); } // if tpl_assign('times', $times); tpl_assign('redirect_to', $redirect_to); } else { $this->redirectTo('administration'); } }
/** * Return manager instance * * @access protected * @param void * @return ProjectTimes */ function manager() { if (!$this->manager instanceof ProjectTimes) { $this->manager = ProjectTimes::instance(); } return $this->manager; }