@@ -0,0 +1,41 | |||
|
1 | # redMine - project management software | |
|
2 | # Copyright (C) 2006-2008 Jean-Philippe Lang | |
|
3 | # | |
|
4 | # This program is free software; you can redistribute it and/or | |
|
5 | # modify it under the terms of the GNU General Public License | |
|
6 | # as published by the Free Software Foundation; either version 2 | |
|
7 | # of the License, or (at your option) any later version. | |
|
8 | # | |
|
9 | # This program is distributed in the hope that it will be useful, | |
|
10 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
|
11 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
|
12 | # GNU General Public License for more details. | |
|
13 | # | |
|
14 | # You should have received a copy of the GNU General Public License | |
|
15 | # along with this program; if not, write to the Free Software | |
|
16 | # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
|
17 | ||
|
18 | class ARCondition | |
|
19 | attr_reader :conditions | |
|
20 | ||
|
21 | def initialize(condition=nil) | |
|
22 | @conditions = ['1=1'] | |
|
23 | @conditions.add(condition) if condition | |
|
24 | end | |
|
25 | ||
|
26 | def add(condition) | |
|
27 | if condition.is_a?(Array) | |
|
28 | @conditions.first << " AND (#{condition.first})" | |
|
29 | @conditions += condition[1..-1] | |
|
30 | elsif condition.is_a?(String) | |
|
31 | @conditions.first << " AND (#{condition})" | |
|
32 | else | |
|
33 | raise "Unsupported #{condition.class} condition: #{condition}" | |
|
34 | end | |
|
35 | self | |
|
36 | end | |
|
37 | ||
|
38 | def <<(condition) | |
|
39 | add(condition) | |
|
40 | end | |
|
41 | end |
|
1 | NO CONTENT: new file 100644, binary diff hidden |
@@ -90,7 +90,11 class ProjectsController < ApplicationController | |||
|
90 | 90 | @trackers = @project.trackers |
|
91 | 91 | @open_issues_by_tracker = Issue.count(:group => :tracker, :joins => "INNER JOIN #{IssueStatus.table_name} ON #{IssueStatus.table_name}.id = #{Issue.table_name}.status_id", :conditions => ["project_id=? and #{IssueStatus.table_name}.is_closed=?", @project.id, false]) |
|
92 | 92 | @total_issues_by_tracker = Issue.count(:group => :tracker, :conditions => ["project_id=?", @project.id]) |
|
93 | @total_hours = @project.time_entries.sum(:hours) | |
|
93 | TimeEntry.visible_by(User.current) do | |
|
94 | @total_hours = TimeEntry.sum(:hours, | |
|
95 | :include => :project, | |
|
96 | :conditions => ["(#{Project.table_name}.id = ? OR #{Project.table_name}.parent_id = ?)", @project.id, @project.id]).to_f | |
|
97 | end | |
|
94 | 98 | @key = User.current.rss_key |
|
95 | 99 | end |
|
96 | 100 |
@@ -26,26 +26,30 class TimelogController < ApplicationController | |||
|
26 | 26 | include TimelogHelper |
|
27 | 27 | |
|
28 | 28 | def report |
|
29 |
@available_criterias = { ' |
|
|
30 |
: |
|
|
29 | @available_criterias = { 'project' => {:sql => "#{TimeEntry.table_name}.project_id", | |
|
30 | :klass => Project, | |
|
31 | :label => :label_project}, | |
|
32 | 'version' => {:sql => "#{Issue.table_name}.fixed_version_id", | |
|
33 | :klass => Version, | |
|
31 | 34 | :label => :label_version}, |
|
32 | 35 | 'category' => {:sql => "#{Issue.table_name}.category_id", |
|
33 |
: |
|
|
36 | :klass => IssueCategory, | |
|
34 | 37 | :label => :field_category}, |
|
35 | 38 | 'member' => {:sql => "#{TimeEntry.table_name}.user_id", |
|
36 |
: |
|
|
39 | :klass => User, | |
|
37 | 40 | :label => :label_member}, |
|
38 | 41 | 'tracker' => {:sql => "#{Issue.table_name}.tracker_id", |
|
39 |
: |
|
|
42 | :klass => Tracker, | |
|
40 | 43 | :label => :label_tracker}, |
|
41 | 44 | 'activity' => {:sql => "#{TimeEntry.table_name}.activity_id", |
|
42 |
: |
|
|
45 | :klass => Enumeration, | |
|
43 | 46 | :label => :label_activity} |
|
44 | 47 | } |
|
45 | 48 | |
|
46 | 49 | @criterias = params[:criterias] || [] |
|
47 | 50 | @criterias = @criterias.select{|criteria| @available_criterias.has_key? criteria} |
|
48 | 51 | @criterias.uniq! |
|
52 | @criterias = @criterias[0,3] | |
|
49 | 53 | |
|
50 | 54 | @columns = (params[:period] && %w(year month week).include?(params[:period])) ? params[:period] : 'month' |
|
51 | 55 | |
@@ -63,8 +67,11 class TimelogController < ApplicationController | |||
|
63 | 67 | sql_group_by = @criterias.collect{|criteria| @available_criterias[criteria][:sql]}.join(', ') |
|
64 | 68 | |
|
65 | 69 | sql = "SELECT #{sql_select}, tyear, tmonth, tweek, SUM(hours) AS hours" |
|
66 | sql << " FROM #{TimeEntry.table_name} LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id" | |
|
67 | sql << " WHERE #{TimeEntry.table_name}.project_id = %s" % @project.id | |
|
70 | sql << " FROM #{TimeEntry.table_name}" | |
|
71 | sql << " LEFT JOIN #{Issue.table_name} ON #{TimeEntry.table_name}.issue_id = #{Issue.table_name}.id" | |
|
72 | sql << " LEFT JOIN #{Project.table_name} ON #{TimeEntry.table_name}.project_id = #{Project.table_name}.id" | |
|
73 | sql << " WHERE (#{Project.table_name}.id = %s OR #{Project.table_name}.parent_id = %s)" % [@project.id, @project.id] | |
|
74 | sql << " AND (%s)" % Project.allowed_to_condition(User.current, :view_time_entries) | |
|
68 | 75 | sql << " AND spent_on BETWEEN '%s' AND '%s'" % [ActiveRecord::Base.connection.quoted_date(@date_from.to_time), ActiveRecord::Base.connection.quoted_date(@date_to.to_time)] |
|
69 | 76 | sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek" |
|
70 | 77 | |
@@ -80,6 +87,8 class TimelogController < ApplicationController | |||
|
80 | 87 | row['week'] = "#{row['tyear']}-#{row['tweek']}" |
|
81 | 88 | end |
|
82 | 89 | end |
|
90 | ||
|
91 | @total_hours = @hours.inject(0) {|s,k| s = s + k['hours'].to_f} | |
|
83 | 92 | end |
|
84 | 93 | |
|
85 | 94 | @periods = [] |
@@ -147,43 +156,46 class TimelogController < ApplicationController | |||
|
147 | 156 | |
|
148 | 157 | @from, @to = @to, @from if @from && @to && @from > @to |
|
149 | 158 | |
|
150 |
cond |
|
|
159 | cond = ARCondition.new | |
|
160 | cond << (@issue.nil? ? ["(#{Project.table_name}.id = ? OR #{Project.table_name}.parent_id = ?)", @project.id, @project.id] : | |
|
161 | ["#{TimeEntry.table_name}.issue_id = ?", @issue.id]) | |
|
162 | ||
|
151 | 163 | if @from |
|
152 | 164 | if @to |
|
153 |
cond |
|
|
165 | cond << ['spent_on BETWEEN ? AND ?', @from, @to] | |
|
154 | 166 | else |
|
155 |
cond |
|
|
167 | cond << ['spent_on >= ?', @from] | |
|
156 | 168 | end |
|
157 | 169 | elsif @to |
|
158 |
cond |
|
|
170 | cond << ['spent_on <= ?', @to] | |
|
159 | 171 | end |
|
160 | 172 | |
|
161 | @owner_id = User.current.id | |
|
162 | ||
|
173 | TimeEntry.visible_by(User.current) do | |
|
163 | 174 | respond_to do |format| |
|
164 | 175 | format.html { |
|
165 | 176 | # Paginate results |
|
166 |
@entry_count = |
|
|
177 | @entry_count = TimeEntry.count(:include => :project, :conditions => cond.conditions) | |
|
167 | 178 | @entry_pages = Paginator.new self, @entry_count, per_page_option, params['page'] |
|
168 |
@entries = |
|
|
169 |
|
|
|
170 |
|
|
|
179 | @entries = TimeEntry.find(:all, | |
|
180 | :include => [:project, :activity, :user, {:issue => :tracker}], | |
|
181 | :conditions => cond.conditions, | |
|
171 | 182 |
|
|
172 | 183 |
|
|
173 | 184 |
|
|
174 |
@total_hours = |
|
|
185 | @total_hours = TimeEntry.sum(:hours, :include => :project, :conditions => cond.conditions).to_f | |
|
175 | 186 | render :layout => !request.xhr? |
|
176 | 187 | } |
|
177 | 188 | format.csv { |
|
178 | 189 | # Export all entries |
|
179 |
@entries = |
|
|
180 |
|
|
|
181 |
|
|
|
190 | @entries = TimeEntry.find(:all, | |
|
191 | :include => [:project, :activity, :user, {:issue => [:tracker, :assigned_to, :priority]}], | |
|
192 | :conditions => cond.conditions, | |
|
182 | 193 |
|
|
183 | 194 | send_data(entries_to_csv(@entries).read, :type => 'text/csv; header=present', :filename => 'timelog.csv') |
|
184 | 195 | } |
|
185 | 196 | end |
|
186 | 197 | end |
|
198 | end | |
|
187 | 199 | |
|
188 | 200 | def edit |
|
189 | 201 | render_404 and return if @time_entry && @time_entry.user != User.current |
@@ -17,7 +17,7 | |||
|
17 | 17 | |
|
18 | 18 | module TimelogHelper |
|
19 | 19 | def select_hours(data, criteria, value) |
|
20 |
data.select {|row| row[criteria] == value |
|
|
20 | data.select {|row| row[criteria] == value} | |
|
21 | 21 | end |
|
22 | 22 | |
|
23 | 23 | def sum_hours(data) |
@@ -50,6 +50,7 module TimelogHelper | |||
|
50 | 50 | headers = [l(:field_spent_on), |
|
51 | 51 | l(:field_user), |
|
52 | 52 | l(:field_activity), |
|
53 | l(:field_project), | |
|
53 | 54 | l(:field_issue), |
|
54 | 55 | l(:field_tracker), |
|
55 | 56 | l(:field_subject), |
@@ -62,6 +63,7 module TimelogHelper | |||
|
62 | 63 | fields = [l_date(entry.spent_on), |
|
63 | 64 | entry.user, |
|
64 | 65 | entry.activity, |
|
66 | entry.project, | |
|
65 | 67 | (entry.issue ? entry.issue.id : nil), |
|
66 | 68 | (entry.issue ? entry.issue.tracker : nil), |
|
67 | 69 | (entry.issue ? entry.issue.subject : nil), |
@@ -110,6 +110,21 class Project < ActiveRecord::Base | |||
|
110 | 110 | end |
|
111 | 111 | end |
|
112 | 112 | |
|
113 | def self.allowed_to_condition(user, permission) | |
|
114 | statements = [] | |
|
115 | active_statement = "#{Project.table_name}.status=#{Project::STATUS_ACTIVE}" | |
|
116 | if user.admin? | |
|
117 | # no restriction | |
|
118 | elsif user.logged? | |
|
119 | statements << "#{Project.table_name}.is_public = #{connection.quoted_true}" if Role.non_member.allowed_to?(permission) | |
|
120 | allowed_project_ids = user.memberships.select {|m| m.role.allowed_to?(permission)}.collect {|m| m.project_id} | |
|
121 | statements << "#{Project.table_name}.id IN (#{allowed_project_ids.join(',')})" | |
|
122 | else | |
|
123 | statements << "#{Project.table_name}.is_public = #{connection.quoted_true}" if Role.anonymous.allowed_to?(permission) | |
|
124 | end | |
|
125 | statements.empty? ? active_statement : "(#{active_statement} AND (#{statements.join(' OR ')}))" | |
|
126 | end | |
|
127 | ||
|
113 | 128 | def self.find(*args) |
|
114 | 129 | if args.first && args.first.is_a?(String) && !args.first.match(/^\d*$/) |
|
115 | 130 | project = find_by_identifier(*args) |
@@ -52,4 +52,10 class TimeEntry < ActiveRecord::Base | |||
|
52 | 52 | def editable_by?(usr) |
|
53 | 53 | usr == self.user |
|
54 | 54 | end |
|
55 | ||
|
56 | def self.visible_by(usr) | |
|
57 | with_scope(:find => { :conditions => Project.allowed_to_condition(usr, :view_time_entries) }) do | |
|
58 | yield | |
|
59 | end | |
|
60 | end | |
|
55 | 61 | end |
@@ -3,6 +3,7 | |||
|
3 | 3 | <%= sort_header_tag('spent_on', :caption => l(:label_date), :default_order => 'desc') %> |
|
4 | 4 | <%= sort_header_tag('user_id', :caption => l(:label_member)) %> |
|
5 | 5 | <%= sort_header_tag('activity_id', :caption => l(:label_activity)) %> |
|
6 | <%= sort_header_tag("#{Project.table_name}.name", :caption => l(:label_project)) %> | |
|
6 | 7 | <%= sort_header_tag('issue_id', :caption => l(:label_issue), :default_order => 'desc') %> |
|
7 | 8 | <th><%= l(:field_comments) %></th> |
|
8 | 9 | <%= sort_header_tag('hours', :caption => l(:field_hours)) %> |
@@ -12,17 +13,16 | |||
|
12 | 13 | <% entries.each do |entry| -%> |
|
13 | 14 | <tr class="time-entry <%= cycle("odd", "even") %>"> |
|
14 | 15 | <td class="spent_on"><%= format_date(entry.spent_on) %></td> |
|
15 |
<td class="user"><%= entry.user |
|
|
16 |
<td class="activity"><%= entry.activity |
|
|
16 | <td class="user"><%=h entry.user %></td> | |
|
17 | <td class="activity"><%=h entry.activity %></td> | |
|
18 | <td class="project"><%=h entry.project %></td> | |
|
17 | 19 | <td class="subject"> |
|
18 | 20 |
|
|
19 |
|
|
|
20 | <span class="tip"><%= render_issue_tooltip entry.issue %></span> | |
|
21 | </div> | |
|
21 | <%= link_to_issue entry.issue %>: <%= h(truncate(entry.issue.subject, 50)) -%> | |
|
22 | 22 |
|
|
23 | 23 | </td> |
|
24 | 24 | <td class="comments"><%=h entry.comments %></td> |
|
25 | <td class="hours"><%= entry.hours %></td> | |
|
25 | <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td> | |
|
26 | 26 | <td align="center"><%= link_to_if_authorized(l(:button_edit), |
|
27 | 27 | {:controller => 'timelog', :action => 'edit', :id => entry}, |
|
28 | 28 | :class => 'icon icon-edit') if entry.editable_by?(User.current) %></td> |
@@ -1,17 +1,17 | |||
|
1 |
<% @ |
|
|
2 | <tr class="<%= cycle('odd', 'even') if criterias.length < level + 2 %>"> | |
|
1 | <% @hours.collect {|h| h[criterias[level]]}.uniq.each do |value| %> | |
|
2 | <% hours_for_value = select_hours(hours, criterias[level], value) -%> | |
|
3 | <% next if hours_for_value.empty? -%> | |
|
4 | <tr class="<%= cycle('odd', 'even') %> <%= 'last-level' unless criterias.length > level+1 %>"> | |
|
3 | 5 | <%= '<td></td>' * level %> |
|
4 | <td><%= value.name %></td> | |
|
5 | <%= '<td></td>' * (criterias.length - level - 1) %> | |
|
6 | <% hours_for_value = select_hours(hours, criterias[level], value.id) %> | |
|
7 | <% @periods.each do |period| %> | |
|
6 | <td><%= value.nil? ? l(:label_none) : @available_criterias[criterias[level]][:klass].find_by_id(value) %></td> | |
|
7 | <%= '<td></td>' * (criterias.length - level - 1) -%> | |
|
8 | <% @periods.each do |period| -%> | |
|
8 | 9 | <% sum = sum_hours(select_hours(hours_for_value, @columns, period.to_s)) %> |
|
9 |
<td |
|
|
10 | <% end %> | |
|
10 | <td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td> | |
|
11 | <% end -%> | |
|
11 | 12 | </tr> |
|
12 | <% if criterias.length > level+1 %> | |
|
13 | <% if criterias.length > level+1 -%> | |
|
13 | 14 | <%= render(:partial => 'report_criteria', :locals => {:criterias => criterias, :hours => hours_for_value, :level => (level + 1)}) %> |
|
14 | <% end %> | |
|
15 | <% end -%> | |
|
15 | 16 | |
|
16 | 17 | <% end %> |
|
17 | <% reset_cycle %> |
@@ -1,4 +1,5 | |||
|
1 | 1 | <div class="contextual"> |
|
2 | <%= link_to(l(:label_report), {:controller => 'timelog', :action => 'report', :project_id => @project}, :class => 'icon icon-report') %> | |
|
2 | 3 | <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :project_id => @project, :issue_id => @issue}, :class => 'icon icon-time' %> |
|
3 | 4 | </div> |
|
4 | 5 | |
@@ -25,7 +26,7 | |||
|
25 | 26 | <%= text_field_tag 'from', @from, :size => 10, :onfocus => '$("period_type_2").checked = true;' %> <%= calendar_for('from') %> |
|
26 | 27 | <%= l(:label_date_to) %> |
|
27 | 28 | <%= text_field_tag 'to', @to, :size => 10, :onfocus => '$("period_type_2").checked = true;' %> <%= calendar_for('to') %> |
|
28 |
<%= submit_tag l(:button_ |
|
|
29 | <%= submit_tag l(:button_apply), :name => nil, :onclick => '$("period_type_2").checked = true;' %> | |
|
29 | 30 | </p> |
|
30 | 31 | </fieldset> |
|
31 | 32 | <% end %> |
@@ -1,31 +1,43 | |||
|
1 | <div class="contextual"> | |
|
2 | <%= link_to(l(:label_details), {:controller => 'timelog', :action => 'details', :project_id => @project}, :class => 'icon icon-details') %> | |
|
3 | <%= link_to_if_authorized l(:button_log_time), {:controller => 'timelog', :action => 'edit', :project_id => @project, :issue_id => @issue}, :class => 'icon icon-time' %> | |
|
4 | </div> | |
|
5 | ||
|
1 | 6 | <h2><%= l(:label_spent_time) %></h2> |
|
2 | 7 | |
|
3 | 8 | <% form_remote_tag(:url => {:project_id => @project}, :update => 'content') do %> |
|
4 | 9 | <% @criterias.each do |criteria| %> |
|
5 | 10 | <%= hidden_field_tag 'criterias[]', criteria %> |
|
6 | 11 | <% end %> |
|
12 | <fieldset><legend><%= l(:label_date_range) %></legend> | |
|
7 | 13 | <p> |
|
8 | <%= l(:label_date_from) %>: <%= text_field_tag 'date_from', @date_from, :size => 10 %><%= calendar_for('date_from') %> | |
|
9 | | |
|
10 | <%= l(:label_date_to) %>: <%= text_field_tag 'date_to', @date_to, :size => 10 %><%= calendar_for('date_to') %> | |
|
11 | | |
|
12 |
<%= l(:label_details) %> |
|
|
14 | <%= l(:label_date_from) %> | |
|
15 | <%= text_field_tag 'date_from', @date_from, :size => 10 %><%= calendar_for('date_from') %> | |
|
16 | <%= l(:label_date_to) %> | |
|
17 | <%= text_field_tag 'date_to', @date_to, :size => 10 %><%= calendar_for('date_to') %> | |
|
18 | <%= l(:label_details) %> | |
|
13 | 19 | <%= select_tag 'period', options_for_select([[l(:label_year), 'year'], |
|
14 | 20 | [l(:label_month), 'month'], |
|
15 | 21 | [l(:label_week), 'week']], @columns) %> |
|
16 | 22 | |
|
17 | 23 | <%= submit_tag l(:button_apply) %> |
|
18 | <%= link_to_remote l(:button_clear), {:url => {:project_id => @project}, :update => 'content'}, :class => 'icon icon-reload' %> | |
|
19 | 24 | </p> |
|
25 | </fieldset> | |
|
20 | 26 | |
|
21 | <% if @criterias.length < 3 %> | |
|
22 | <p><%= l(:button_add) %>: <%= select_tag('criterias[]', options_for_select([[]] + (@available_criterias.keys - @criterias).collect{|k| [l(@available_criterias[k][:label]), k]}), :onchange => "this.form.onsubmit();") %></p> | |
|
23 | <% end %> | |
|
24 | ||
|
25 | <br /> | |
|
27 | <p><%= l(:button_add) %>: <%= select_tag('criterias[]', options_for_select([[]] + (@available_criterias.keys - @criterias).collect{|k| [l(@available_criterias[k][:label]), k]}), | |
|
28 | :onchange => "this.form.onsubmit();", | |
|
29 | :style => 'width: 200px', | |
|
30 | :disabled => (@criterias.length >= 3)) %> | |
|
31 | <%= link_to_remote l(:button_clear), {:url => {:project_id => @project, :date_from => @date_from, :date_to => @date_to, :period => @columns}, :update => 'content'}, | |
|
32 | :class => 'icon icon-reload' %></p> | |
|
26 | 33 | |
|
27 | 34 |
<% unless @criterias.empty? %> |
|
28 | <table class="list"> | |
|
35 | <div class="total-hours"> | |
|
36 | <p><%= l(:label_total) %>: <%= html_hours(lwr(:label_f_hour, @total_hours)) %></p> | |
|
37 | </div> | |
|
38 | ||
|
39 | <% unless @hours.empty? %> | |
|
40 | <table class="list" id="time-report"> | |
|
29 | 41 | <thead> |
|
30 | 42 | <tr> |
|
31 | 43 | <% @criterias.each do |criteria| %> |
@@ -36,13 +48,21 | |||
|
36 | 48 | <% end %> |
|
37 | 49 | </tr> |
|
38 | 50 | </thead> |
|
39 | ||
|
40 | 51 | <tbody> |
|
41 | 52 | <%= render :partial => 'report_criteria', :locals => {:criterias => @criterias, :hours => @hours, :level => 0} %> |
|
53 | <tr class="total"> | |
|
54 | <td><%= l(:label_total) %></td> | |
|
55 | <%= '<td></td>' * (@criterias.size - 1) %> | |
|
56 | <% @periods.each do |period| -%> | |
|
57 | <% sum = sum_hours(select_hours(@hours, @columns, period.to_s)) %> | |
|
58 | <td class="hours"><%= html_hours("%.2f" % sum) if sum > 0 %></td> | |
|
59 | <% end -%> | |
|
60 | </tr> | |
|
42 | 61 | </tbody> |
|
43 | 62 | </table> |
|
44 | 63 | <% end %> |
|
45 | 64 | <% end %> |
|
65 | <% end %> | |
|
46 | 66 | |
|
47 | 67 | <% content_for :header_tags do %> |
|
48 | 68 | <%= javascript_include_tag 'calendar/calendar' %> |
@@ -112,7 +112,8 tr.user.locked a, tr.user.registered a { color: #aaa; } | |||
|
112 | 112 | |
|
113 | 113 | tr.time-entry { text-align: center; white-space: nowrap; } |
|
114 | 114 | tr.time-entry td.subject, tr.time-entry td.comments { text-align: left; } |
|
115 |
tr.time-entry td.hours { text-align: right; font-weight: bold; padding-right: 0. |
|
|
115 | tr.time-entry td.hours { text-align: right; font-weight: bold; padding-right: 0.5em; } | |
|
116 | tr.time-entry .hours-dec { font-size: 0.9em; } | |
|
116 | 117 | |
|
117 | 118 | table.list tbody tr:hover { background-color:#ffffdd; } |
|
118 | 119 | table td {padding:2px;} |
@@ -173,6 +174,12 div#roadmap .wiki h1:first-child { display: none; } | |||
|
173 | 174 | div#roadmap .wiki h1 { font-size: 120%; } |
|
174 | 175 | div#roadmap .wiki h2 { font-size: 110%; } |
|
175 | 176 | |
|
177 | table#time-report td.hours { text-align: right; padding-right: 0.5em; } | |
|
178 | table#time-report tbody tr { font-style: italic; color: #777; } | |
|
179 | table#time-report tbody tr.last-level { font-style: normal; color: #555; } | |
|
180 | table#time-report tbody tr.total { font-style: normal; font-weight: bold; color: #555; background-color:#EEEEEE; } | |
|
181 | table#time-report .hours-dec { font-size: 0.9em; } | |
|
182 | ||
|
176 | 183 | div.total-hours { text-align: left; font-size: 110%; font-weight: bold; } |
|
177 | 184 | div.total-hours span.hours-int { font-size: 120%; } |
|
178 | 185 | |
@@ -536,6 +543,8 vertical-align: middle; | |||
|
536 | 543 | .icon-lock { background-image: url(../images/locked.png); } |
|
537 | 544 | .icon-unlock { background-image: url(../images/unlock.png); } |
|
538 | 545 | .icon-checked { background-image: url(../images/true.png); } |
|
546 | .icon-details { background-image: url(../images/zoom_in.png); } | |
|
547 | .icon-report { background-image: url(../images/report.png); } | |
|
539 | 548 | |
|
540 | 549 | .icon22-projects { background-image: url(../images/22x22/projects.png); } |
|
541 | 550 | .icon22-users { background-image: url(../images/22x22/users.png); } |
@@ -6,7 +6,7 time_entries_001: | |||
|
6 | 6 | project_id: 1 |
|
7 | 7 | comments: My hours |
|
8 | 8 | updated_on: 2007-03-23 12:54:18 +01:00 |
|
9 |
activity_id: |
|
|
9 | activity_id: 9 | |
|
10 | 10 | spent_on: 2007-03-23 |
|
11 | 11 | issue_id: 1 |
|
12 | 12 | id: 1 |
@@ -20,7 +20,7 time_entries_002: | |||
|
20 | 20 | project_id: 1 |
|
21 | 21 | comments: "" |
|
22 | 22 | updated_on: 2007-03-23 14:11:04 +01:00 |
|
23 |
activity_id: |
|
|
23 | activity_id: 9 | |
|
24 | 24 | spent_on: 2007-03-12 |
|
25 | 25 | issue_id: 1 |
|
26 | 26 | id: 2 |
@@ -34,10 +34,25 time_entries_003: | |||
|
34 | 34 | project_id: 1 |
|
35 | 35 | comments: "" |
|
36 | 36 | updated_on: 2007-04-21 12:20:48 +02:00 |
|
37 |
activity_id: |
|
|
37 | activity_id: 9 | |
|
38 | 38 | spent_on: 2007-04-21 |
|
39 | 39 | issue_id: 2 |
|
40 | 40 | id: 3 |
|
41 | 41 | hours: 1.0 |
|
42 | 42 | user_id: 1 |
|
43 | 43 | tyear: 2007 |
|
44 | time_entries_004: | |
|
45 | created_on: 2007-04-22 12:20:48 +02:00 | |
|
46 | tweek: 16 | |
|
47 | tmonth: 4 | |
|
48 | project_id: 3 | |
|
49 | comments: Time spent on a subproject | |
|
50 | updated_on: 2007-04-22 12:20:48 +02:00 | |
|
51 | activity_id: 10 | |
|
52 | spent_on: 2007-04-22 | |
|
53 | issue_id: | |
|
54 | id: 4 | |
|
55 | hours: 7.65 | |
|
56 | user_id: 1 | |
|
57 | tyear: 2007 | |
|
58 | No newline at end of file |
@@ -37,17 +37,27 class TimelogControllerTest < Test::Unit::TestCase | |||
|
37 | 37 | end |
|
38 | 38 | |
|
39 | 39 | def test_report_one_criteria |
|
40 |
get :report, :project_id => 1, :period => |
|
|
40 | get :report, :project_id => 1, :period => 'week', :date_from => "2007-04-01", :date_to => "2007-04-30", :criterias => ['project'] | |
|
41 | 41 | assert_response :success |
|
42 | 42 | assert_template 'report' |
|
43 | assert_not_nil assigns(:hours) | |
|
43 | assert_not_nil assigns(:total_hours) | |
|
44 | assert_equal "8.65", "%.2f" % assigns(:total_hours) | |
|
44 | 45 |
|
|
45 | 46 | |
|
46 | 47 | def test_report_two_criterias |
|
47 |
get :report, :project_id => 1, :period => |
|
|
48 | get :report, :project_id => 1, :period => 'month', :date_from => "2007-01-01", :date_to => "2007-12-31", :criterias => ["member", "activity"] | |
|
49 | assert_response :success | |
|
50 | assert_template 'report' | |
|
51 | assert_not_nil assigns(:total_hours) | |
|
52 | assert_equal "162.90", "%.2f" % assigns(:total_hours) | |
|
53 | end | |
|
54 | ||
|
55 | def test_report_one_criteria_no_result | |
|
56 | get :report, :project_id => 1, :period => 'week', :date_from => "1998-04-01", :date_to => "1998-04-30", :criterias => ['project'] | |
|
48 | 57 | assert_response :success |
|
49 | 58 | assert_template 'report' |
|
50 | assert_not_nil assigns(:hours) | |
|
59 | assert_not_nil assigns(:total_hours) | |
|
60 | assert_equal "0.00", "%.2f" % assigns(:total_hours) | |
|
51 | 61 |
|
|
52 | 62 | |
|
53 | 63 | def test_details_at_project_level |
@@ -55,9 +65,11 class TimelogControllerTest < Test::Unit::TestCase | |||
|
55 | 65 | assert_response :success |
|
56 | 66 | assert_template 'details' |
|
57 | 67 | assert_not_nil assigns(:entries) |
|
58 |
assert_equal |
|
|
68 | assert_equal 4, assigns(:entries).size | |
|
69 | # project and subproject | |
|
70 | assert_equal [1, 3], assigns(:entries).collect(&:project_id).uniq.sort | |
|
59 | 71 | assert_not_nil assigns(:total_hours) |
|
60 |
assert_equal |
|
|
72 | assert_equal "162.90", "%.2f" % assigns(:total_hours) | |
|
61 | 73 | # display all time by default |
|
62 | 74 | assert_nil assigns(:from) |
|
63 | 75 | assert_nil assigns(:to) |
@@ -68,9 +80,9 class TimelogControllerTest < Test::Unit::TestCase | |||
|
68 | 80 | assert_response :success |
|
69 | 81 | assert_template 'details' |
|
70 | 82 | assert_not_nil assigns(:entries) |
|
71 |
assert_equal |
|
|
83 | assert_equal 3, assigns(:entries).size | |
|
72 | 84 | assert_not_nil assigns(:total_hours) |
|
73 |
assert_equal |
|
|
85 | assert_equal "12.90", "%.2f" % assigns(:total_hours) | |
|
74 | 86 | assert_equal '2007-03-20'.to_date, assigns(:from) |
|
75 | 87 | assert_equal '2007-04-30'.to_date, assigns(:to) |
|
76 | 88 | end |
General Comments 0
You need to be logged in to leave comments.
Login now