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.
71 lines
2.2 KiB
71 lines
2.2 KiB
15 years ago
|
require_dependency 'timelog_controller'
|
||
|
|
||
12 years ago
|
module OpenProject::Costs::Patches::TimelogControllerPatch
|
||
15 years ago
|
def self.included(base) # :nodoc:
|
||
|
base.send(:include, InstanceMethods)
|
||
14 years ago
|
|
||
15 years ago
|
base.class_eval do
|
||
|
unloadable
|
||
14 years ago
|
|
||
12 years ago
|
alias_method_chain :index, :reports_view
|
||
|
alias_method_chain :find_optional_project, :own
|
||
15 years ago
|
end
|
||
|
end
|
||
14 years ago
|
|
||
15 years ago
|
module InstanceMethods
|
||
14 years ago
|
|
||
|
##
|
||
|
# @Override
|
||
|
# This is for cost reporting
|
||
|
def redirect_to(*args, &block)
|
||
|
if args.first == :back and args.size == 1 and request.referer =~ /cost_reports/
|
||
|
super(:controller => 'cost_reports', :action => :index)
|
||
|
else
|
||
14 years ago
|
super(*args, &block)
|
||
14 years ago
|
end
|
||
|
end
|
||
|
|
||
12 years ago
|
def index_with_reports_view
|
||
15 years ago
|
# we handle single project reporting currently
|
||
12 years ago
|
return index_without_reports_view if @project.nil?
|
||
15 years ago
|
filters = {:operators => {}, :values => {}}
|
||
15 years ago
|
|
||
|
if @issue
|
||
|
if @issue.respond_to?("lft")
|
||
|
issue_ids = Issue.all(:select => :id, :conditions => ["root_id = ? AND lft >= ? AND rgt <= ?", @issue.root_id, @issue.lft, @issue.rgt]).collect{|i| i.id.to_s}
|
||
|
else
|
||
|
issue_ids = [@issue.id.to_s]
|
||
|
end
|
||
|
|
||
15 years ago
|
filters[:operators][:issue_id] = "="
|
||
|
filters[:values][:issue_id] = [issue_ids]
|
||
15 years ago
|
end
|
||
15 years ago
|
|
||
|
filters[:operators][:project_id] = "="
|
||
|
filters[:values][:project_id] = [@project.id.to_s]
|
||
15 years ago
|
respond_to do |format|
|
||
|
format.html {
|
||
14 years ago
|
session[CostQuery.name.underscore.to_sym] = { :filters => filters, :groups => {:rows => [], :columns => []} }
|
||
14 years ago
|
redirect_to :controller => "cost_reports", :action => "index", :project_id => @project, :unit => -1
|
||
15 years ago
|
}
|
||
|
format.all {
|
||
12 years ago
|
index_without_report_view
|
||
15 years ago
|
}
|
||
|
end
|
||
|
end
|
||
12 years ago
|
|
||
|
def find_optional_project_with_own
|
||
|
if !params[:issue_id].blank?
|
||
|
@issue = Issue.find(params[:issue_id])
|
||
|
@project = @issue.project
|
||
|
elsif !params[:project_id].blank?
|
||
|
@project = Project.find(params[:project_id])
|
||
|
end
|
||
|
deny_access unless User.current.allowed_to?(:view_time_entries, @project, :global => true) ||
|
||
|
User.current.allowed_to?(:view_own_time_entries, @project, :global => true)
|
||
|
end
|
||
15 years ago
|
end
|
||
|
end
|
||
|
|
||
12 years ago
|
TimelogController.send(:include, OpenProject::Costs::Patches::TimelogControllerPatch)
|