remove trailing white-spaces from app/controllers/time_entry_reports_controller.rb.
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@6868 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
parent
b21374891d
commit
011b505f9a
|
@ -16,16 +16,16 @@ class TimeEntryReportsController < ApplicationController
|
||||||
@criterias = @criterias.select{|criteria| @available_criterias.has_key? criteria}
|
@criterias = @criterias.select{|criteria| @available_criterias.has_key? criteria}
|
||||||
@criterias.uniq!
|
@criterias.uniq!
|
||||||
@criterias = @criterias[0,3]
|
@criterias = @criterias[0,3]
|
||||||
|
|
||||||
@columns = (params[:columns] && %w(year month week day).include?(params[:columns])) ? params[:columns] : 'month'
|
@columns = (params[:columns] && %w(year month week day).include?(params[:columns])) ? params[:columns] : 'month'
|
||||||
|
|
||||||
retrieve_date_range
|
retrieve_date_range
|
||||||
|
|
||||||
unless @criterias.empty?
|
unless @criterias.empty?
|
||||||
sql_select = @criterias.collect{|criteria| @available_criterias[criteria][:sql] + " AS " + criteria}.join(', ')
|
sql_select = @criterias.collect{|criteria| @available_criterias[criteria][:sql] + " AS " + criteria}.join(', ')
|
||||||
sql_group_by = @criterias.collect{|criteria| @available_criterias[criteria][:sql]}.join(', ')
|
sql_group_by = @criterias.collect{|criteria| @available_criterias[criteria][:sql]}.join(', ')
|
||||||
sql_condition = ''
|
sql_condition = ''
|
||||||
|
|
||||||
if @project.nil?
|
if @project.nil?
|
||||||
sql_condition = Project.allowed_to_condition(User.current, :view_time_entries)
|
sql_condition = Project.allowed_to_condition(User.current, :view_time_entries)
|
||||||
elsif @issue.nil?
|
elsif @issue.nil?
|
||||||
|
@ -41,9 +41,9 @@ class TimeEntryReportsController < ApplicationController
|
||||||
sql << " (%s) AND" % sql_condition
|
sql << " (%s) AND" % sql_condition
|
||||||
sql << " (spent_on BETWEEN '%s' AND '%s')" % [ActiveRecord::Base.connection.quoted_date(@from), ActiveRecord::Base.connection.quoted_date(@to)]
|
sql << " (spent_on BETWEEN '%s' AND '%s')" % [ActiveRecord::Base.connection.quoted_date(@from), ActiveRecord::Base.connection.quoted_date(@to)]
|
||||||
sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek, spent_on"
|
sql << " GROUP BY #{sql_group_by}, tyear, tmonth, tweek, spent_on"
|
||||||
|
|
||||||
@hours = ActiveRecord::Base.connection.select_all(sql)
|
@hours = ActiveRecord::Base.connection.select_all(sql)
|
||||||
|
|
||||||
@hours.each do |row|
|
@hours.each do |row|
|
||||||
case @columns
|
case @columns
|
||||||
when 'year'
|
when 'year'
|
||||||
|
@ -56,9 +56,9 @@ class TimeEntryReportsController < ApplicationController
|
||||||
row['day'] = "#{row['spent_on']}"
|
row['day'] = "#{row['spent_on']}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@total_hours = @hours.inject(0) {|s,k| s = s + k['hours'].to_f}
|
@total_hours = @hours.inject(0) {|s,k| s = s + k['hours'].to_f}
|
||||||
|
|
||||||
@periods = []
|
@periods = []
|
||||||
# Date#at_beginning_of_ not supported in Rails 1.2.x
|
# Date#at_beginning_of_ not supported in Rails 1.2.x
|
||||||
date_from = @from.to_time
|
date_from = @from.to_time
|
||||||
|
@ -80,13 +80,13 @@ class TimeEntryReportsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html { render :layout => !request.xhr? }
|
format.html { render :layout => !request.xhr? }
|
||||||
format.csv { send_data(report_to_csv(@criterias, @periods, @hours), :type => 'text/csv; header=present', :filename => 'timelog.csv') }
|
format.csv { send_data(report_to_csv(@criterias, @periods, @hours), :type => 'text/csv; header=present', :filename => 'timelog.csv') }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
# TODO: duplicated in TimelogController
|
# TODO: duplicated in TimelogController
|
||||||
|
@ -141,7 +141,7 @@ class TimeEntryReportsController < ApplicationController
|
||||||
else
|
else
|
||||||
# default
|
# default
|
||||||
end
|
end
|
||||||
|
|
||||||
@from, @to = @to, @from if @from && @to && @from > @to
|
@from, @to = @to, @from if @from && @to && @from > @to
|
||||||
@from ||= (TimeEntry.earilest_date_for_project(@project) || Date.today)
|
@from ||= (TimeEntry.earilest_date_for_project(@project) || Date.today)
|
||||||
@to ||= (TimeEntry.latest_date_for_project(@project) || Date.today)
|
@to ||= (TimeEntry.latest_date_for_project(@project) || Date.today)
|
||||||
|
@ -170,7 +170,7 @@ class TimeEntryReportsController < ApplicationController
|
||||||
:klass => Issue,
|
:klass => Issue,
|
||||||
:label => :label_issue}
|
:label => :label_issue}
|
||||||
}
|
}
|
||||||
|
|
||||||
# Add list and boolean custom fields as available criterias
|
# Add list and boolean custom fields as available criterias
|
||||||
custom_fields = (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields)
|
custom_fields = (@project.nil? ? IssueCustomField.for_all : @project.all_issue_custom_fields)
|
||||||
custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
custom_fields.select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
||||||
|
@ -178,7 +178,7 @@ class TimeEntryReportsController < ApplicationController
|
||||||
:format => cf.field_format,
|
:format => cf.field_format,
|
||||||
:label => cf.name}
|
:label => cf.name}
|
||||||
end if @project
|
end if @project
|
||||||
|
|
||||||
# Add list and boolean time entry custom fields
|
# Add list and boolean time entry custom fields
|
||||||
TimeEntryCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
TimeEntryCustomField.find(:all).select {|cf| %w(list bool).include? cf.field_format }.each do |cf|
|
||||||
@available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'TimeEntry' AND c.customized_id = #{TimeEntry.table_name}.id)",
|
@available_criterias["cf_#{cf.id}"] = {:sql => "(SELECT c.value FROM #{CustomValue.table_name} c WHERE c.custom_field_id = #{cf.id} AND c.customized_type = 'TimeEntry' AND c.customized_id = #{TimeEntry.table_name}.id)",
|
||||||
|
|
Loading…
Reference in New Issue