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.
62 lines
2.3 KiB
62 lines
2.3 KiB
module DeliverablesHelper
|
|
include ApplicationHelper
|
|
|
|
# Check if the current user is allowed to manage the budget. Based on Role
|
|
# permissions.
|
|
def allowed_management?
|
|
return User.current.allowed_to?(:edit_deliverables, @project)
|
|
end
|
|
|
|
def fields_for_deliverable_cost(deliverable_cost, &block)
|
|
prefix = deliverable_cost.new_record? ? "new" : "existing"
|
|
fields_for("deliverable[#{prefix}_deliverable_cost_attributes][]", deliverable_cost, &block)
|
|
end
|
|
|
|
def deliverables_to_csv(deliverables, project)
|
|
ic = Iconv.new(l(:general_csv_encoding), 'UTF-8')
|
|
decimal_separator = l(:general_csv_decimal_separator)
|
|
export = StringIO.new
|
|
CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
|
|
# csv header fields
|
|
headers = [ "#",
|
|
l(:field_status),
|
|
l(:field_project),
|
|
l(:field_subject),
|
|
l(:field_score),
|
|
l(:field_author),
|
|
l(:field_fixed_date),
|
|
l(:field_materials_budget),
|
|
l(:field_labor_budget),
|
|
l(:field_spent),
|
|
l(:field_created_on),
|
|
l(:field_updated_on),
|
|
l(:field_description)
|
|
]
|
|
csv << headers.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
|
# csv lines
|
|
deliverables.each do |issue|
|
|
fields = [issue.id,
|
|
deliverable.status.name,
|
|
deliverable.project.name,
|
|
deliverable.subject,
|
|
deliverable.score,
|
|
deliverable.author.name,
|
|
format_date(deliverable.fixed_date),
|
|
deliverable.kind == "CostBasedDeliverable" ? number_to_currency(deliverable.materials_budget) : "",
|
|
deliverable.kind == "CostBasedDeliverable" ? number_to_currency(deliverable.labor_budget) : "",
|
|
deliverable.kind == "CostBasedDeliverable" ? number_to_currency(deliverable.spent) : "",
|
|
format_time(deliverable.created_on),
|
|
format_time(deliverable.updated_on),
|
|
deliverable.description
|
|
]
|
|
csv << fields.collect {|c| begin; ic.iconv(c.to_s); rescue; c.to_s; end }
|
|
end
|
|
end
|
|
export.rewind
|
|
export
|
|
end
|
|
|
|
|
|
|
|
|
|
end |