/** * Show a object properties * * Parameters: * * - object - Object of which properties are shown * - show_completed_status - To display object completed status * - show_milestone - To display object milestone * - show_tags - To display object tags * - show_body - To display object description * - show_category - To display object category * - show_file_details - To display file details, if object is file * - show_name - To display object name * - show_priority - To display object priority * - show_milestone_day_info - To display milestone due on info * - show_assignees - To show assignees * - only_show_body - To display only body * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_mobile_access_object_properties($params, &$smarty) { $object = array_var($params, 'object'); if (!instance_of($object, 'ProjectObject')) { return new InvalidParamError('object', $object, '$object is expected to be an instance of ProjectObject class', true); } // if $smarty->assign(array('_mobile_access_object_properties_object' => $object, '_mobile_access_object_properties_show_completed_status' => (bool) array_var($params, 'show_completed_status', false), '_mobile_access_object_properties_show_milestone' => (bool) array_var($params, 'show_milestone', false), '_mobile_access_object_properties_show_tags' => (bool) array_var($params, 'show_tags', false), '_mobile_access_object_properties_show_body' => (bool) array_var($params, 'show_body', false), '_mobile_access_object_properties_show_category' => (bool) array_var($params, 'show_category', false), '_mobile_access_object_properties_show_file_details' => (bool) array_var($params, 'show_file_details', false), '_mobile_access_object_properties_show_name' => (bool) array_var($params, 'show_name', false), '_mobile_access_object_properties_show_assignees' => (bool) array_var($params, 'show_assignees', false), '_mobile_access_object_properties_show_priority' => (bool) array_var($params, 'show_priority', false), '_mobile_access_object_properties_show_milestone_day_info' => (bool) array_var($params, 'show_milestone_day_info', false), '_mobile_access_object_properties_show_total_time' => (bool) array_var($params, 'show_total_time', false), '_mobile_access_object_properties_only_show_body' => (bool) array_var($params, 'only_show_body', false))); if (module_loaded(TIMETRACKING_MODULE)) { $smarty->assign(array('_mobile_access_object_properties_total_time' => float_format(TimeRecords::sumObjectTime($object), 2))); } return $smarty->fetch(get_template_path('_object_properties', null, MOBILE_ACCESS_MODULE)); }
/** * Render object time widget * * @param array $params * @param Smarty $smarty * @return string */ function smarty_function_object_time($params, &$smarty) { if (!module_loaded('timetracking')) { return ''; } // if $object = array_var($params, 'object'); if (!instance_of($object, 'ProjectObject')) { return new InvalidParamError('$object', $object, '$object is expected to be a valid instance of ProjectObject class'); } // if $show_time = ''; $additional_class = ''; if (array_var($params, 'show_time', true)) { $object_time = TimeRecords::sumObjectTime($object); if ($object->can_have_tasks) { $tasks_time = TimeRecords::sumTasksTime($object); } else { $tasks_time = 0; } // if $additional_class = 'with_text'; $total_time = $object_time + $tasks_time; if ($object_time == 0 && $tasks_time == 0) { $show_time = '<span class="time_widget_text">' . lang('No time tracked') . '</span> '; } elseif ($tasks_time == 0) { $show_time = '<span class="time_widget_text">' . lang(':total hours logged', array('total' => float_format($total_time, 2))) . '</span> '; } else { $show_time = '<span class="time_widget_text">' . lang(':total hours logged - :object_time for the ticket and :tasks_time for tasks', array('type' => $object->getVerboseType(true), 'total' => float_format($total_time, 2), 'object_time' => float_format($object_time, 2), 'tasks_time' => float_format($tasks_time, 2))) . '</span> '; } // if } // if $wrapper_id = 'object_time_widget_' . $object->getId(); $image_url = $object->getHasTime() ? get_image_url('clock-small.gif') : get_image_url('gray-clock-small.gif'); return '<span id="' . $wrapper_id . '" class="time_popup_widget ' . $additional_class . '">' . $show_time . '<a href="' . $object->getTimeUrl() . '" title="' . lang('Time') . '"><img src="' . $image_url . '" alt="" /></a></span><script type="text/javascript">App.TimePopup.init("' . $wrapper_id . '")</script>'; }
/** * 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; }
/** * Utility method that will update parents has_time flag * * @param void * @return boolean */ function refreshParentHasTime() { $parent = $this->getParent(); if (instance_of($parent, 'ProjectObject')) { $parent->setHasTime((bool) TimeRecords::sumObjectTime($parent)); return $parent->save(); } // if return true; }