_timelog.rhtml

Petr Pospisil, 2010-06-08 12:19

Download (2.27 KB)

 
1
XX
2
<h3><%=l(:label_spent_time)%> (<%= l(:label_last_n_days, 7) %>)</h3>
3
<% 
4
entries = TimeEntry.find(:all,
5
                                :conditions => ["#{TimeEntry.table_name}.user_id = ? AND #{TimeEntry.table_name}.spent_on BETWEEN ? AND ?", user.id, Date.today - 6, Date.today],
6
                                :include => [:activity, :project, {:issue => [:tracker, :status]}],
7
                                :order => "#{TimeEntry.table_name}.spent_on DESC, #{Project.table_name}.name ASC, #{Tracker.table_name}.position ASC, #{Issue.table_name}.id ASC")
8
entries_by_day = entries.group_by(&:spent_on)
9
%>
10

    
11
<div class="total-hours">
12
<p><%= l(:label_total) %>: <%= html_hours("%.2f" % entries.sum(&:hours).to_f) %></p>
13
</div>
14

    
15
<% if entries.any? %>
16
<table class="list time-entries">
17
<thead>
18
<th><%= l(:label_activity) %></th>
19
<th><%= l(:label_project) %></th>
20
<th><%= l(:field_comments) %></th>
21
<th><%= l(:field_hours) %></th>
22
<th></th>
23
</thead>
24
<tbody>
25
<% entries_by_day.keys.sort.reverse.each do |day| %>
26
    <tr class="odd">
27
    <td><strong><%= day == Date.today ? l(:label_today).titleize : format_date(day) %></strong></td>
28
    <td colspan="2"></td>
29
    <td class="hours"><em><%= html_hours("%.2f" % entries_by_day[day].sum(&:hours).to_f) %></em></td>
30
    <td></td>
31
    </tr>
32
    <% entries_by_day[day].each do |entry| -%>
33
    <tr class="time-entry" style="border-bottom: 1px solid #f5f5f5;">
34
    <td class="activity"><%=h entry.activity %></td>
35
    <td class="subject"><%=h entry.project %> <%= ' - ' + link_to_issue(entry.issue, :truncate => 50) if entry.issue %></td>
36
    <td class="comments"><%=h entry.comments %></td>
37
    <td class="hours"><%= html_hours("%.2f" % entry.hours) %></td>
38
    <td align="center">
39
    <% if entry.editable_by?(user) -%>
40
        <%= link_to image_tag('edit.png'), {:controller => 'timelog', :action => 'edit', :id => entry},
41
                                           :title => l(:button_edit) %>
42
        <%= link_to image_tag('delete.png'), {:controller => 'timelog', :action => 'destroy', :id => entry},
43
                                             :confirm => l(:text_are_you_sure),
44
                                             :method => :post,
45
                                             :title => l(:button_delete) %>
46
    <% end -%>
47
    </td>
48
    </tr>
49
    <% end -%>
50
<% end -%>
51
</tbody>
52
</table>
53
<% end %>