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