@@ -142,6 +142,7 module TimelogHelper | |||
|
142 | 142 | end |
|
143 | 143 | |
|
144 | 144 | def report_to_csv(criterias, periods, hours) |
|
145 | decimal_separator = l(:general_csv_decimal_separator) | |
|
145 | 146 | export = FCSV.generate(:col_sep => l(:general_csv_separator)) do |csv| |
|
146 | 147 | # Column headers |
|
147 | 148 | headers = criterias.collect {|criteria| l(@available_criterias[criteria][:label]) } |
@@ -159,15 +160,16 module TimelogHelper | |||
|
159 | 160 | periods.each do |period| |
|
160 | 161 | sum = sum_hours(select_hours(hours, @columns, period.to_s)) |
|
161 | 162 | total += sum |
|
162 | row << (sum > 0 ? "%.2f" % sum : '') | |
|
163 | row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '') | |
|
163 | 164 | end |
|
164 | row << "%.2f" %total | |
|
165 | row << ("%.2f" % total).gsub('.',decimal_separator) | |
|
165 | 166 | csv << row |
|
166 | 167 | end |
|
167 | 168 | export |
|
168 | 169 | end |
|
169 | 170 | |
|
170 | 171 | def report_criteria_to_csv(csv, criterias, periods, hours, level=0) |
|
172 | decimal_separator = l(:general_csv_decimal_separator) | |
|
171 | 173 | hours.collect {|h| h[criterias[level]].to_s}.uniq.each do |value| |
|
172 | 174 | hours_for_value = select_hours(hours, criterias[level], value) |
|
173 | 175 | next if hours_for_value.empty? |
@@ -180,11 +182,10 module TimelogHelper | |||
|
180 | 182 | periods.each do |period| |
|
181 | 183 | sum = sum_hours(select_hours(hours_for_value, @columns, period.to_s)) |
|
182 | 184 | total += sum |
|
183 | row << (sum > 0 ? "%.2f" % sum : '') | |
|
185 | row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '') | |
|
184 | 186 | end |
|
185 | row << "%.2f" %total | |
|
187 | row << ("%.2f" % total).gsub('.',decimal_separator) | |
|
186 | 188 | csv << row |
|
187 | ||
|
188 | 189 | if criterias.length > level + 1 |
|
189 | 190 | report_criteria_to_csv(csv, criterias, periods, hours_for_value, level + 1) |
|
190 | 191 | end |
General Comments 0
You need to be logged in to leave comments.
Login now