diff options
author | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-02-26 18:15:58 +0000 |
---|---|---|
committer | Jean-Philippe Lang <jp_lang@yahoo.fr> | 2008-02-26 18:15:58 +0000 |
commit | 328df74dd1779963b80317b72e56aa2a4ea5e2f2 (patch) | |
tree | bc34c905768eeae2106de016d9887ba106c14a8a /app/helpers/timelog_helper.rb | |
parent | 792b7f30e32eec84d6106e947fc3987e4e26a0b0 (diff) | |
download | redmine-328df74dd1779963b80317b72e56aa2a4ea5e2f2.tar.gz redmine-328df74dd1779963b80317b72e56aa2a4ea5e2f2.zip |
Adds date range filter and pagination on time entries detail view (closes #434).
git-svn-id: http://redmine.rubyforge.org/svn/trunk@1173 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'app/helpers/timelog_helper.rb')
-rw-r--r-- | app/helpers/timelog_helper.rb | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/app/helpers/timelog_helper.rb b/app/helpers/timelog_helper.rb index 22e4eba0b..2af748f6f 100644 --- a/app/helpers/timelog_helper.rb +++ b/app/helpers/timelog_helper.rb @@ -27,4 +27,51 @@ module TimelogHelper end sum end + + def options_for_period_select(value) + options_for_select([[l(:label_all_time), 'all'], + [l(:label_today), 'today'], + [l(:label_yesterday), 'yesterday'], + [l(:label_this_week), 'current_week'], + [l(:label_last_week), 'last_week'], + [l(:label_last_n_days, 7), '7_days'], + [l(:label_this_month), 'current_month'], + [l(:label_last_month), 'last_month'], + [l(:label_last_n_days, 30), '30_days'], + [l(:label_this_year), 'current_year']], + value) + end + + def entries_to_csv(entries) + ic = Iconv.new(l(:general_csv_encoding), 'UTF-8') + export = StringIO.new + CSV::Writer.generate(export, l(:general_csv_separator)) do |csv| + # csv header fields + headers = [l(:field_spent_on), + l(:field_user), + l(:field_activity), + l(:field_issue), + l(:field_tracker), + l(:field_subject), + l(:field_hours), + l(:field_comments) + ] + csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end } + # csv lines + entries.each do |entry| + fields = [l_date(entry.spent_on), + entry.user, + entry.activity, + (entry.issue ? entry.issue.id : nil), + (entry.issue ? entry.issue.tracker : nil), + (entry.issue ? entry.issue.subject : nil), + entry.hours, + entry.comments + ] + csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end } + end + end + export.rewind + export + end end |