Index: app/helpers/timelog_helper.rb
===================================================================
--- app/helpers/timelog_helper.rb (revision 1144)
+++ app/helpers/timelog_helper.rb (working copy)
@@ -27,4 +27,11 @@
end
sum
end
+
+ def render_time_entry_tooltip(time_entry)
+ @cached_label_comments ||= l(:field_comments)
+
+ issue = time_entry.issue.nil? ? "" : link_to_issue(time_entry.issue) + ": #{h(time_entry.issue.subject)}
"
+ issue + "#{@cached_label_comments}: #{time_entry.comments}"
+ end
end
Index: app/controllers/my_controller.rb
===================================================================
--- app/controllers/my_controller.rb (revision 1144)
+++ app/controllers/my_controller.rb (working copy)
@@ -17,6 +17,7 @@
class MyController < ApplicationController
helper :issues
+ helper :timelog
layout 'base'
before_filter :require_login
@@ -26,7 +27,8 @@
'issueswatched' => :label_watched_issues,
'news' => :label_news_latest,
'calendar' => :label_calendar,
- 'documents' => :label_document_plural
+ 'documents' => :label_document_plural,
+ 'mytimereport' => :label_my_time_report
}.freeze
DEFAULT_LAYOUT = { 'left' => ['issuesassignedtome'],
Index: app/views/my/blocks/_mytimereport.rhtml
===================================================================
--- app/views/my/blocks/_mytimereport.rhtml (revision 0)
+++ app/views/my/blocks/_mytimereport.rhtml (revision 0)
@@ -0,0 +1,9 @@
+
<%= l(:label_my_time_report) %>
+
+<% calendar = Redmine::Helpers::TimeReportCalendar.new(Date.today, current_language, :week2)
+ calendar.time_entries = TimeEntry.find :all,
+ :conditions => ["(user_id = #{@user.id}) AND (spent_on>=? and spent_on<=?)", calendar.startdt, calendar.enddt],
+ :include => [:project, :activity] unless @user.projects.empty?
+%>
+
+<%= render :partial => 'common/mytimereportcalendar', :locals => {:calendar => calendar } %>
Index: app/views/common/_mytimereportcalendar.rhtml
===================================================================
--- app/views/common/_mytimereportcalendar.rhtml (revision 0)
+++ app/views/common/_mytimereportcalendar.rhtml (revision 0)
@@ -0,0 +1,30 @@
+
+
+
+ | <% 7.times do |i| %><%= day_name( (calendar.first_wday+i)%7 ) %> | <% end %>
+
+
+
+<% day = calendar.startdt
+while day <= calendar.enddt %>
+<%= "#{day.cweek} | " if day.cwday == calendar.first_wday %>
+
+ <%= day.day %>
+<% day_hours = 0 %>
+<% calendar.time_entries_on(day).each do |i| %>
+ <% day_hours += i.hours %>
+
+ <%= h("#{i.project.name} - #{i.activity.name} : #{i.hours}") %>
+ <%= render_time_entry_tooltip i %>
+
+<% end %>
+<% if day_hours > 0 %>
+ <%= h("TOTAL: #{day_hours}") %>
+<% end %>
+ |
+<%= '
' if day.cwday==calendar.last_wday and day!=calendar.enddt %>
+<% day = day + 1
+end %>
+
+
+
Index: lang/en.yml
===================================================================
--- lang/en.yml (revision 1144)
+++ lang/en.yml (working copy)
@@ -477,6 +477,7 @@
label_general: General
label_more: More
label_scm: SCM
+label_my_time_report: My time report
button_login: Login
button_submit: Submit
Index: lib/redmine/helpers/time_report_calendar.rb
===================================================================
--- lib/redmine/helpers/time_report_calendar.rb (revision 0)
+++ lib/redmine/helpers/time_report_calendar.rb (revision 0)
@@ -0,0 +1,57 @@
+# redMine - project management software
+# Copyright (C) 2006-2007 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+module Redmine
+ module Helpers
+
+ #class for calculating personal time entries
+ class TimeReportCalendar < Calendar
+ def initialize(date, lang = current_language, period = :week2)
+ @date = date
+ @events = []
+ @ending_events_by_days = {}
+ @starting_events_by_days = {}
+
+ @time_entries = []
+ @spent_time_entries_by_days = {}
+
+ set_language lang
+
+ case period
+ when :week2
+ @startdt = date - 7 - (date.cwday - first_wday)%7
+ @enddt = date + (last_wday - date.cwday)%7
+ else
+ super(date, lang, period)
+ end
+ end
+
+ # Sets calendar time_entries
+ def time_entries=(time_entries)
+ @time_entries = time_entries
+ @spent_time_entries_by_days = @time_entries.group_by {|entry| entry.spent_on}
+ end
+
+ # Returns time_entries for the given day
+ def time_entries_on(day)
+ @spent_time_entries_by_days[day] || []
+ end
+
+ end
+
+ end
+end