##// END OF EJS Templates
remove trailing white-spaces from app/helpers/timelog_helper.rb....
Toshi MARUYAMA -
r6791:dbc616c928bc
parent child
Show More
@@ -1,23 +1,23
1 # redMine - project management software
2 # Copyright (C) 2006 Jean-Philippe Lang
1 # Redmine - project management software
2 # Copyright (C) 2006-2011 Jean-Philippe Lang
3 3 #
4 4 # This program is free software; you can redistribute it and/or
5 5 # modify it under the terms of the GNU General Public License
6 6 # as published by the Free Software Foundation; either version 2
7 7 # of the License, or (at your option) any later version.
8 #
8 #
9 9 # This program is distributed in the hope that it will be useful,
10 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 12 # GNU General Public License for more details.
13 #
13 #
14 14 # You should have received a copy of the GNU General Public License
15 15 # along with this program; if not, write to the Free Software
16 16 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 17
18 18 module TimelogHelper
19 19 include ApplicationHelper
20
20
21 21 def render_timelog_breadcrumb
22 22 links = []
23 23 links << link_to(l(:label_project_all), {:project_id => nil, :issue_id => nil})
@@ -52,15 +52,15 module TimelogHelper
52 52 activities.each { |a| collection << [a.name, a.id] }
53 53 collection
54 54 end
55
55
56 56 def select_hours(data, criteria, value)
57 57 if value.to_s.empty?
58 58 data.select {|row| row[criteria].blank? }
59 else
59 else
60 60 data.select {|row| row[criteria].to_s == value.to_s}
61 61 end
62 62 end
63
63
64 64 def sum_hours(data)
65 65 sum = 0
66 66 data.each do |row|
@@ -68,7 +68,7 module TimelogHelper
68 68 end
69 69 sum
70 70 end
71
71
72 72 def options_for_period_select(value)
73 73 options_for_select([[l(:label_all_time), 'all'],
74 74 [l(:label_today), 'today'],
@@ -82,9 +82,9 module TimelogHelper
82 82 [l(:label_this_year), 'current_year']],
83 83 value)
84 84 end
85
85
86 86 def entries_to_csv(entries)
87 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
87 ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
88 88 decimal_separator = l(:general_csv_decimal_separator)
89 89 custom_fields = TimeEntryCustomField.find(:all)
90 90 export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
@@ -101,7 +101,7 module TimelogHelper
101 101 ]
102 102 # Export custom fields
103 103 headers += custom_fields.collect(&:name)
104
104
105 105 csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
106 106 # csv lines
107 107 entries.each do |entry|
@@ -116,13 +116,13 module TimelogHelper
116 116 entry.comments
117 117 ]
118 118 fields += custom_fields.collect {|f| show_value(entry.custom_value_for(f)) }
119
119
120 120 csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
121 121 end
122 122 end
123 123 export
124 124 end
125
125
126 126 def format_criteria_value(criteria, value)
127 127 if value.blank?
128 128 l(:label_none)
@@ -137,7 +137,7 module TimelogHelper
137 137 format_value(value, @available_criterias[criteria][:format])
138 138 end
139 139 end
140
140
141 141 def report_to_csv(criterias, periods, hours)
142 142 export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv|
143 143 # Column headers
@@ -160,7 +160,7 module TimelogHelper
160 160 end
161 161 export
162 162 end
163
163
164 164 def report_criteria_to_csv(csv, criterias, periods, hours, level=0)
165 165 hours.collect {|h| h[criterias[level]].to_s}.uniq.each do |value|
166 166 hours_for_value = select_hours(hours, criterias[level], value)
@@ -176,13 +176,13 module TimelogHelper
176 176 end
177 177 row << "%.2f" %total
178 178 csv << row
179
179
180 180 if criterias.length > level + 1
181 181 report_criteria_to_csv(csv, criterias, periods, hours_for_value, level + 1)
182 182 end
183 183 end
184 184 end
185
185
186 186 def to_utf8(s)
187 187 @ic ||= Iconv.new(l(:general_csv_encoding), 'UTF-8')
188 188 begin; @ic.iconv(s.to_s); rescue; s.to_s; end
General Comments 0
You need to be logged in to leave comments. Login now