Patch #655 » MY_TIME_REPORT.diff
app/helpers/timelog_helper.rb (working copy) | ||
---|---|---|
27 | 27 |
end |
28 | 28 |
sum |
29 | 29 |
end |
30 | ||
31 |
def render_time_entry_tooltip(time_entry) |
|
32 |
@cached_label_comments ||= l(:field_comments) |
|
33 | ||
34 |
issue = time_entry.issue.nil? ? "" : link_to_issue(time_entry.issue) + ": #{h(time_entry.issue.subject)}<br />" |
|
35 |
issue + "<strong>#{@cached_label_comments}</strong>: #{time_entry.comments}" |
|
36 |
end |
|
30 | 37 |
end |
app/controllers/my_controller.rb (working copy) | ||
---|---|---|
17 | 17 | |
18 | 18 |
class MyController < ApplicationController |
19 | 19 |
helper :issues |
20 |
helper :timelog |
|
20 | 21 |
|
21 | 22 |
layout 'base' |
22 | 23 |
before_filter :require_login |
... | ... | |
26 | 27 |
'issueswatched' => :label_watched_issues, |
27 | 28 |
'news' => :label_news_latest, |
28 | 29 |
'calendar' => :label_calendar, |
29 |
'documents' => :label_document_plural |
|
30 |
'documents' => :label_document_plural, |
|
31 |
'mytimereport' => :label_my_time_report |
|
30 | 32 |
}.freeze |
31 | 33 | |
32 | 34 |
DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'], |
app/views/my/blocks/_mytimereport.rhtml (revision 0) | ||
---|---|---|
1 |
<h3><%= l(:label_my_time_report) %></h3> |
|
2 | ||
3 |
<% calendar = Redmine::Helpers::TimeReportCalendar.new(Date.today, current_language, :week2) |
|
4 |
calendar.time_entries = TimeEntry.find :all, |
|
5 |
:conditions => ["(user_id = #{@user.id}) AND (spent_on>=? and spent_on<=?)", calendar.startdt, calendar.enddt], |
|
6 |
:include => [:project, :activity] unless @user.projects.empty? |
|
7 |
%> |
|
8 | ||
9 |
<%= render :partial => 'common/mytimereportcalendar', :locals => {:calendar => calendar } %> |
app/views/common/_mytimereportcalendar.rhtml (revision 0) | ||
---|---|---|
1 |
<table class="cal"> |
|
2 |
<thead> |
|
3 | ||
4 |
<tr><td></td><% 7.times do |i| %><th><%= day_name( (calendar.first_wday+i)%7 ) %></th><% end %></tr> |
|
5 |
</thead> |
|
6 |
<tbody> |
|
7 |
<tr> |
|
8 |
<% day = calendar.startdt |
|
9 |
while day <= calendar.enddt %> |
|
10 |
<%= "<th>#{day.cweek}</th>" if day.cwday == calendar.first_wday %> |
|
11 |
<td class="<%= day.month==calendar.month ? 'even' : 'odd' %><%= ' today' if Date.today == day %>"> |
|
12 |
<p class="day-num"><%= day.day %></p> |
|
13 |
<% day_hours = 0 %> |
|
14 |
<% calendar.time_entries_on(day).each do |i| %> |
|
15 |
<% day_hours += i.hours %> |
|
16 |
<div class="tooltip"> |
|
17 |
<%= h("#{i.project.name} - #{i.activity.name} : #{i.hours}") %> |
|
18 |
<span class="tip"><%= render_time_entry_tooltip i %></span> |
|
19 |
</div> |
|
20 |
<% end %> |
|
21 |
<% if day_hours > 0 %> |
|
22 |
<%= h("TOTAL: #{day_hours}") %> |
|
23 |
<% end %> |
|
24 |
</td> |
|
25 |
<%= '</tr><tr>' if day.cwday==calendar.last_wday and day!=calendar.enddt %> |
|
26 |
<% day = day + 1 |
|
27 |
end %> |
|
28 |
</tr> |
|
29 |
</tbody> |
|
30 |
</table> |
lang/en.yml (working copy) | ||
---|---|---|
477 | 477 |
label_general: General |
478 | 478 |
label_more: More |
479 | 479 |
label_scm: SCM |
480 |
label_my_time_report: My time report |
|
480 | 481 | |
481 | 482 |
button_login: Login |
482 | 483 |
button_submit: Submit |
lib/redmine/helpers/time_report_calendar.rb (revision 0) | ||
---|---|---|
1 |
# redMine - project management software |
|
2 |
# Copyright (C) 2006-2007 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 |
module Redmine |
|
19 |
module Helpers |
|
20 | ||
21 |
#class for calculating personal time entries |
|
22 |
class TimeReportCalendar < Calendar |
|
23 |
def initialize(date, lang = current_language, period = :week2) |
|
24 |
@date = date |
|
25 |
@events = [] |
|
26 |
@ending_events_by_days = {} |
|
27 |
@starting_events_by_days = {} |
|
28 | ||
29 |
@time_entries = [] |
|
30 |
@spent_time_entries_by_days = {} |
|
31 | ||
32 |
set_language lang |
|
33 | ||
34 |
case period |
|
35 |
when :week2 |
|
36 |
@startdt = date - 7 - (date.cwday - first_wday)%7 |
|
37 |
@enddt = date + (last_wday - date.cwday)%7 |
|
38 |
else |
|
39 |
super(date, lang, period) |
|
40 |
end |
|
41 |
end |
|
42 | ||
43 |
# Sets calendar time_entries |
|
44 |
def time_entries=(time_entries) |
|
45 |
@time_entries = time_entries |
|
46 |
@spent_time_entries_by_days = @time_entries.group_by {|entry| entry.spent_on} |
|
47 |
end |
|
48 | ||
49 |
# Returns time_entries for the given day |
|
50 |
def time_entries_on(day) |
|
51 |
@spent_time_entries_by_days[day] || [] |
|
52 |
end |
|
53 | ||
54 |
end |
|
55 | ||
56 |
end |
|
57 |
end |
- « Previous
- 1
- 2
- Next »