##// END OF EJS Templates
remove trailing white space from test/fixtures/workflows.yml...
remove trailing white space from test/fixtures/workflows.yml git-svn-id: http://svn.redmine.org/redmine/trunk@16339 e93f8b46-1217-0410-a6f0-8f06a7374b81

File last commit:

r15262:03dbf8abb881
r15957:7816a4025a03 master
Show More
timelog_helper.rb
121 lines | 4.0 KiB | text/x-ruby | RubyLexer
/ app / helpers / timelog_helper.rb
Jean-Philippe Lang
Added encoding comment to helpers (#9792)....
r8090 # encoding: utf-8
#
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/timelog_helper.rb....
r6791 # Redmine - project management software
Jean-Philippe Lang
Updates copyright for 2016....
r14856 # Copyright (C) 2006-2016 Jean-Philippe Lang
Jean-Philippe Lang
Added time report....
r569 #
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/timelog_helper.rb....
r6791 #
Jean-Philippe Lang
Added time report....
r569 # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/timelog_helper.rb....
r6791 #
Jean-Philippe Lang
Added time report....
r569 # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
Jean-Philippe Lang
Simple time tracking functionality added. Time can be logged at issue or project level....
r365 module TimelogHelper
Jean-Philippe Lang
Fixed: Details time log report CSV export doesn't honour date format from settings (patch #2466 by Russell Hind)....
r2300 include ApplicationHelper
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/timelog_helper.rb....
r6791
Eric Davis
Added an active field track if an Enumeration is active on the frontend view....
r2832 # Returns a collection of activities for a select field. time_entry
# is optional and will be used to check if the selected TimeEntryActivity
# is active.
Eric Davis
Changed the Timelogs to use both the Systemwide and Project specific TimeEntryActivities...
r2834 def activity_collection_for_select_options(time_entry=nil, project=nil)
Jean-Philippe Lang
Update activities list when changing project/issue id on the time entry form (#19656)....
r13905 project ||= time_entry.try(:project)
Eric Davis
Changed the Timelogs to use both the Systemwide and Project specific TimeEntryActivities...
r2834 project ||= @project
if project.nil?
Jean-Philippe Lang
Changes misleading scopes on Enumeration....
r2969 activities = TimeEntryActivity.shared.active
Eric Davis
Changed the Timelogs to use both the Systemwide and Project specific TimeEntryActivities...
r2834 else
activities = project.activities
end
Jean-Philippe Lang
Addq "please select" to activity select box if no activity is set as default (#937)....
r1588 collection = []
Eric Davis
Changed the Timelogs to use both the Systemwide and Project specific TimeEntryActivities...
r2834 if time_entry && time_entry.activity && !time_entry.activity.active?
Eric Davis
Added an active field track if an Enumeration is active on the frontend view....
r2832 collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ]
else
collection << [ "--- #{l(:actionview_instancetag_blank_option)} ---", '' ] unless activities.detect(&:is_default)
end
Jean-Philippe Lang
Addq "please select" to activity select box if no activity is set as default (#937)....
r1588 activities.each { |a| collection << [a.name, a.id] }
collection
end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/timelog_helper.rb....
r6791
Jean-Philippe Lang
Added time report....
r569 def select_hours(data, criteria, value)
Toshi MARUYAMA
replace tabs to spaces at app/helpers/timelog_helper.rb...
r11176 if value.to_s.empty?
data.select {|row| row[criteria].blank? }
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/timelog_helper.rb....
r6791 else
Toshi MARUYAMA
replace tabs to spaces at app/helpers/timelog_helper.rb...
r11176 data.select {|row| row[criteria].to_s == value.to_s}
Jean-Philippe Lang
Show timelog reports for non-versioned issues (#3051)....
r2554 end
Jean-Philippe Lang
Added time report....
r569 end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/timelog_helper.rb....
r6791
Jean-Philippe Lang
Added time report....
r569 def sum_hours(data)
sum = 0
data.each do |row|
sum += row['hours'].to_f
end
sum
end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/timelog_helper.rb....
r6791
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 def format_criteria_value(criteria_options, value)
Jean-Philippe Lang
Don't reveal issue subjects if user is only allowed to view spent time (#3187)....
r2929 if value.blank?
Jean-Philippe Lang
Display "none" inside square brackets....
r8524 "[#{l(:label_none)}]"
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 elsif k = criteria_options[:klass]
Jean-Philippe Lang
Don't reveal issue subjects if user is only allowed to view spent time (#3187)....
r2929 obj = k.find_by_id(value.to_i)
if obj.is_a?(Issue)
Toshi MARUYAMA
backout r6356: HTML escape of app/helpers/timelog_helper.rb...
r7821 obj.visible? ? "#{obj.tracker} ##{obj.id}: #{obj.subject}" : "##{obj.id}"
Jean-Philippe Lang
Don't reveal issue subjects if user is only allowed to view spent time (#3187)....
r2929 else
obj
end
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 elsif cf = criteria_options[:custom_field]
format_value(value, cf)
Jean-Philippe Lang
Don't reveal issue subjects if user is only allowed to view spent time (#3187)....
r2929 else
Jean-Philippe Lang
Merged custom fields format refactoring....
r12125 value.to_s
Jean-Philippe Lang
Don't reveal issue subjects if user is only allowed to view spent time (#3187)....
r2929 end
Jean-Philippe Lang
Custom fields (list and boolean) can be used as criteria in time report (#1012)....
r1325 end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/timelog_helper.rb....
r6791
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 def report_to_csv(report)
Jean-Philippe Lang
Adds a class for handling CSV generation (#7037)....
r13920 Redmine::Export::CSV.generate do |csv|
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 # Column headers
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 headers = report.criteria.collect {|criteria| l(report.available_criteria[criteria][:label]) }
headers += report.periods
Jean-Philippe Lang
Adds label_total_time string (#13337)....
r11352 headers << l(:label_total_time)
Jean-Philippe Lang
Adds a class for handling CSV generation (#7037)....
r13920 csv << headers
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 # Content
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 report_criteria_to_csv(csv, report.available_criteria, report.columns, report.criteria, report.periods, report.hours)
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 # Total row
Jean-Philippe Lang
Adds a class for handling CSV generation (#7037)....
r13920 str_total = l(:label_total_time)
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 row = [ str_total ] + [''] * (report.criteria.size - 1)
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 total = 0
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 report.periods.each do |period|
sum = sum_hours(select_hours(report.hours, report.columns, period.to_s))
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 total += sum
Jean-Philippe Lang
Adds a class for handling CSV generation (#7037)....
r13920 row << (sum > 0 ? sum : '')
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 end
Jean-Philippe Lang
Adds a class for handling CSV generation (#7037)....
r13920 row << total
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 csv << row
end
end
Toshi MARUYAMA
remove trailing white-spaces from app/helpers/timelog_helper.rb....
r6791
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 def report_criteria_to_csv(csv, available_criteria, columns, criteria, periods, hours, level=0)
hours.collect {|h| h[criteria[level]].to_s}.uniq.each do |value|
hours_for_value = select_hours(hours, criteria[level], value)
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 next if hours_for_value.empty?
row = [''] * level
Jean-Philippe Lang
Adds a class for handling CSV generation (#7037)....
r13920 row << format_criteria_value(available_criteria[criteria[level]], value).to_s
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 row += [''] * (criteria.length - level - 1)
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 total = 0
periods.each do |period|
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 sum = sum_hours(select_hours(hours_for_value, columns, period.to_s))
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 total += sum
Jean-Philippe Lang
Adds a class for handling CSV generation (#7037)....
r13920 row << (sum > 0 ? sum : '')
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 end
Jean-Philippe Lang
Adds a class for handling CSV generation (#7037)....
r13920 row << total
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 csv << row
Jean-Philippe Lang
Extracted time report logic from the controller....
r7906 if criteria.length > level + 1
report_criteria_to_csv(csv, available_criteria, columns, criteria, periods, hours_for_value, level + 1)
Jean-Philippe Lang
CSV export added to timelog report (#1009)....
r1323 end
end
end
Jean-Philippe Lang
Simple time tracking functionality added. Time can be logged at issue or project level....
r365 end