kanbanworkflowstimelinescrumrubyroadmapproject-planningproject-managementopenprojectangularissue-trackerifcgantt-chartganttbug-trackerboardsbcf
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
69 lines
2.1 KiB
69 lines
2.1 KiB
11 years ago
|
#-- copyright
|
||
|
# OpenProject Costs Plugin
|
||
|
#
|
||
|
# Copyright (C) 2009 - 2014 the OpenProject Foundation (OPF)
|
||
|
#
|
||
|
# This program is free software; you can redistribute it and/or
|
||
|
# modify it under the terms of the GNU General Public License
|
||
|
# version 3.
|
||
|
#
|
||
|
# 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.
|
||
|
#
|
||
|
# 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.
|
||
|
#++
|
||
|
|
||
16 years ago
|
module CostlogHelper
|
||
|
include TimelogHelper
|
||
13 years ago
|
|
||
16 years ago
|
def render_costlog_breadcrumb
|
||
|
links = []
|
||
9 years ago
|
links << link_to(t(:label_project_all), project_id: nil, work_package_id: nil)
|
||
9 years ago
|
links << link_to(h(@project), project_id: @project, work_package_id: nil) if @project
|
||
9 years ago
|
links << link_to_work_package(@work_package, subject: false) if @work_package
|
||
16 years ago
|
breadcrumb links
|
||
|
end
|
||
13 years ago
|
|
||
15 years ago
|
def cost_types_collection_for_select_options(selected_type = nil)
|
||
9 years ago
|
cost_types = CostType.active.sort
|
||
15 years ago
|
|
||
|
if selected_type && !cost_types.include?(selected_type)
|
||
|
cost_types << selected_type
|
||
|
cost_types.sort
|
||
|
end
|
||
9 years ago
|
cost_types.map { |t| [t.name, t.id] }
|
||
16 years ago
|
end
|
||
13 years ago
|
|
||
9 years ago
|
def user_collection_for_select_options(_options = {})
|
||
11 years ago
|
users = @project.possible_assignees
|
||
9 years ago
|
users.map { |t| [t.name, t.id] }
|
||
16 years ago
|
end
|
||
13 years ago
|
|
||
9 years ago
|
def extended_progress_bar(pcts, options = {})
|
||
15 years ago
|
return progress_bar(pcts, options) unless pcts.is_a?(Numeric) && pcts > 100
|
||
13 years ago
|
|
||
7 years ago
|
closed = ((100.0 / pcts) * 100).round
|
||
|
done = 100.0 - ((100.0 / pcts) * 100).round
|
||
|
progress_bar([closed, done], options)
|
||
15 years ago
|
end
|
||
13 years ago
|
|
||
15 years ago
|
def clean_currency(value)
|
||
9 years ago
|
return nil if value.nil? || value == ''
|
||
15 years ago
|
|
||
|
value = value.strip
|
||
9 years ago
|
value.gsub!(t(:currency_delimiter), '') if value.include?(t(:currency_delimiter)) && value.include?(t(:currency_separator))
|
||
15 years ago
|
value.gsub(',', '.')
|
||
15 years ago
|
BigDecimal.new(value)
|
||
15 years ago
|
end
|
||
13 years ago
|
|
||
12 years ago
|
def to_currency_with_empty(rate)
|
||
|
rate.nil? ?
|
||
9 years ago
|
'0.0' :
|
||
12 years ago
|
number_to_currency(rate.rate)
|
||
|
end
|
||
|
end
|