/**
  * Render popup content
  *
  * @param void
  * @return null
  */
 function _render_popup_content()
 {
     if (!instance_of($this->active_object, 'ProjectObject')) {
         $this->httpError(HTTP_ERR_NOT_FOUND);
     }
     // if
     if (TimeRecord::canAdd($this->logged_user, $this->active_project)) {
         $add_record_url = timetracking_module_add_record_url($this->active_project, array('for' => $this->active_object->getId(), 'for_popup_dialog' => 1));
     } else {
         $add_record_url = false;
     }
     // if
     $object_time = TimeRecords::sumObjectTime($this->active_object);
     $tasks_time = $this->active_object->can_have_tasks ? TimeRecords::sumTasksTime($this->active_object) : 0;
     $this->smarty->assign(array('selected_user' => $this->logged_user, 'selected_date' => new DateValue(time() + get_user_gmt_offset($this->logged_user)), 'selected_billable_status' => BILLABLE_STATUS_BILLABLE, 'object_time' => float_format($object_time, 2), 'tasks_time' => float_format($tasks_time, 2), 'total_time' => float_format($object_time + $tasks_time, 2), 'add_url' => $add_record_url));
     $this->smarty->display(get_template_path('_popup', null, TIMETRACKING_MODULE));
     die;
 }
示例#2
0
/**
 * Returns true if $user can track time for $object
 *
 * @param User $user
 * @param ProjectObject $object
 * @return boolean
 */
function timetracking_can_add_for($user, $object)
{
    return TimeRecord::canAddFor($user, $object);
}
 /**
  * Returns true if $user can track time for $object
  *
  * @param User $user
  * @param ProjectObject $object
  * @return boolean
  */
 function canAddFor($user, $object)
 {
     return (instance_of($object, 'Task') || instance_of($object, 'Ticket')) && TimeRecord::canAdd($user, $object->getProject());
 }