annotate app/views/my/blocks/_timelog.rhtml @ 507:0c939c159af4 redmine-1.2

Update to Redmine 1.2.1 on 1.2-stable branch (Redmine SVN rev 6270)
author Chris Cannam
date Thu, 14 Jul 2011 10:32:19 +0100
parents 94944d00e43c
children
rev   line source
Chris@0 1 <h3><%=l(:label_spent_time)%> (<%= l(:label_last_n_days, 7) %>)</h3>
Chris@0 2 <%
Chris@0 3 entries = TimeEntry.find(:all,
Chris@0 4 :conditions => ["#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", @user.id, Date.today - 6, Date.today],
Chris@0 5 :include => [:activity, :project, {:issue => [:tracker, :status]}],
Chris@0 6 :order => "#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC")
Chris@0 7 entries_by_day = entries.group_by(&:spent_on)
Chris@0 8 %>
Chris@0 9
Chris@0 10 <div class="total-hours">
Chris@0 11 <p><%= l(:label_total) %>: <%= html_hours("%.2f" % entries.sum(&:hours).to_f) %></p>
Chris@0 12 </div>
Chris@0 13
Chris@0 14 <% if entries.any? %>
Chris@0 15 <table class="list time-entries">
Chris@0 16 <thead><tr>
Chris@0 17 <th><%= l(:label_activity) %></th>
Chris@0 18 <th><%= l(:label_project) %></th>
Chris@0 19 <th><%= l(:field_comments) %></th>
Chris@0 20 <th><%= l(:field_hours) %></th>
Chris@0 21 <th></th>
Chris@0 22 </tr></thead>
Chris@0 23 <tbody>
Chris@0 24 <% entries_by_day.keys.sort.reverse.each do |day| %>
Chris@0 25 <tr class="odd">
Chris@0 26 <td><strong><%= day == Date.today ? l(:label_today).titleize : format_date(day) %></strong></td>
Chris@0 27 <td colspan="2"></td>
Chris@0 28 <td class="hours"><em><%= html_hours("%.2f" % entries_by_day[day].sum(&:hours).to_f) %></em></td>
Chris@0 29 <td></td>
Chris@0 30 </tr>
Chris@0 31 <% entries_by_day[day].each do |entry| -%>
Chris@0 32 <tr class="time-entry" style="border-bottom: 1px solid #f5f5f5;">
Chris@0 33 <td class="activity"><%=h entry.activity %></td>
Chris@0 34 <td class="subject"><%=h entry.project %> <%= ' - ' + link_to_issue(entry.issue, :truncate => 50) if entry.issue %></td>
Chris@0 35 <td class="comments"><%=h entry.comments %></td>
Chris@0 36 <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
Chris@0 37 <td align="center">
Chris@0 38 <% if entry.editable_by?(@user) -%>
Chris@0 39 <%= link_to image_tag('edit.png'), {:controller => 'timelog', :action => 'edit', :id => entry},
Chris@0 40 :title => l(:button_edit) %>
Chris@0 41 <%= link_to image_tag('delete.png'), {:controller => 'timelog', :action => 'destroy', :id => entry},
Chris@0 42 :confirm => l(:text_are_you_sure),
chris@37 43 :method => :delete,
Chris@0 44 :title => l(:button_delete) %>
Chris@0 45 <% end -%>
Chris@0 46 </td>
Chris@0 47 </tr>
Chris@0 48 <% end -%>
Chris@0 49 <% end -%>
Chris@0 50 </tbody>
Chris@0 51 </table>
Chris@0 52 <% end %>