2008年4月7日月曜日

Redmineに工数確認機能を追加2

工数入力は同じ課題がしばらく続くことが多いので、
入力補助として履歴に最近入力した課題への工数入力のリンクを増やしてみた。

----------------------------------------
app/views/my/blocks/_hourhistories.rhtml
----------------------------------------
<h3>入力工数履歴</h3>

<ul>
<% sql =
"select user_id, spent_on, sum(hours) as day_hour" +
" from time_entries" +
" where user_id = #{user.id}" +
" group by spent_on" +
" order by spent_on desc" +
" limit 5"-%>
<% for entry in TimeEntry.find_by_sql(sql) %>
<li><%= "#{entry.spent_on}: #{entry.day_hour} h" %>
<% end %>
</ul>

<%= link_to "詳細", :controller => "man_hour" %>
<p>
<% sql =
"select distinct issue_id " +
" from time_entries" +
" where user_id = #{user.id}" +
" order by spent_on desc" +
" limit 10"-%>
<h3>最近工数入力した課題</h3>
<ul>
<% i = 0 %>
<% for entry in TimeEntry.find_by_sql(sql) %>
<% if entry.issue %>
<li>[<%= link_to '工数入力', :controller => 'timelog', :action => 'edit', :issue_id => entry.issue_id %>]
<%= link_to_issue entry.issue %> <%= entry.issue.subject %>
<% end %>
<% end %>
</ul>