timelog_helper.patch
redmine/app/helpers/timelog_helper.rb 20110517 09:12:48.182807069 +0200  

139  139 
end 
140  140 

141  141 
def report_to_csv(criterias, periods, hours) 
142 
decimal_separator = l(:general_csv_decimal_separator) 

143  
142  144 
export = FCSV.generate(:col_sep => l(:general_csv_separator)) do csv 
143  145 
# Column headers 
144  146 
headers = criterias.collect {criteria l(@available_criterias[criteria][:label]) } 
...  ...  
153  155 
periods.each do period 
154  156 
sum = sum_hours(select_hours(hours, @columns, period.to_s)) 
155  157 
total += sum 
156 
row << (sum > 0 ? "%.2f" % sum : '')


158 
row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '')


157  159 
end 
158 
row << "%.2f" %total


160 
row << ("%.2f" %total).gsub('.',decimal_separator)


159  161 
csv << row 
160  162 
end 
161  163 
export 
162  164 
end 
163  165 

164  166 
def report_criteria_to_csv(csv, criterias, periods, hours, level=0) 
167 
decimal_separator = l(:general_csv_decimal_separator) 

168 


165  169 
hours.collect {h h[criterias[level]].to_s}.uniq.each do value 
166  170 
hours_for_value = select_hours(hours, criterias[level], value) 
167  171 
next if hours_for_value.empty? 
...  ...  
172  176 
periods.each do period 
173  177 
sum = sum_hours(select_hours(hours_for_value, @columns, period.to_s)) 
174  178 
total += sum 
175 
row << (sum > 0 ? "%.2f" % sum : '')


179 
row << (sum > 0 ? ("%.2f" % sum).gsub('.',decimal_separator) : '')


176  180 
end 
177 
row << "%.2f" %total


181 
row << ("%.2f" %total).gsub('.',decimal_separator)


178  182 
csv << row 
179  183 

180  184 
if criterias.length > level + 1 