added initial structures for cost report

git-svn-id: https://dev.finn.de/svn/cockpit/trunk@165 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
hjust 15 years ago
parent 968bf2a0e2
commit 0c3631914c
  1. 15
      app/controllers/cost_reports_controller.rb
  2. 3
      app/helpers/cost_reports_helper.rb
  3. 61
      app/models/cost_query.rb
  4. 0
      app/views/cost_reports/index.rhtml
  5. 12
      init.rb

@ -0,0 +1,15 @@
class CostReportsController < ApplicationController
unloadable
before_filter :get_query
def index
end
private
def get_query
# tries to find a active query in the session or loads the default one
end
end

@ -0,0 +1,3 @@
module CostReportsHelper
include QueriesHelper
end

@ -0,0 +1,61 @@
require_dependency 'query'
class CostQueryColumn < QueryColumn
attr_accessor :name, :sortable, :groupable, :default_order
def initialize(name, options={})
self.type = (optione.delete(:type) || 'issue')
super
end
end
class CostQuery < ActiveRecord::Base
belongs_to :user
belongs_to :project
serialize :filters
serialize :group_by
attr_protected :user_id, :project_id, :created_at, :updated_at
def self.operators
Query.operators
end
def operators_by_filter_type
Query.operators_by_filter_type
end
def available_filters
# This available_filters is different from the Redmine one
# available_filters[:issues]
# --> filters on issue fields. These are the one from redmine itself
# available_filters[:costs]
# --> filters on cost and time entries
return @available_filters if @available_filters
@available_filters = {
:costs => {
"cost_type_id" => { :type => :list_optional, :order => 2, :applies => [:cost_entries], :values => CostType.find(:all, :order => 'name').collect{|s| [s.name, s.id.to_s] }},
"activity" => { :type => :list_optional, :order => 3, :applies => [:time_entries], :values => Enumeration.find(:all, :conditions => ['opt=?','ACTI'], :order => 'position').collect{|s| [s.name, s.id.to_s] }},
"created_on" => { :type => :date_past, :applies => [:time_entries, :cost_entries], :order => 4 },
"updated_on" => { :type => :date_past, :applies => [:time_entries, :cost_entries], :order => 5 },
"spent_on" => { :type => :date, :applies => [:time_entries, :cost_entries], :order => 6 }
"overridden" => { :type => }
},
}
tmp_query = Query.new(:project => project)
@available_filters[:issues] = tmp_query.available_filters
if @available_filters[:issues]["author_id"]
# add a filter on cost entries for user_id if it is available
user_values = @available_filters[:issues]["author_id"][:values]
@available_filters[:costs]["user_id"] = {:type => :list_optional, :order => 1, :applies => [:time_entries, :cost_entries], :values => user_values}
end
@available_filters
end
end

@ -55,12 +55,12 @@ Redmine::Plugin.register :redmine_costs do
# Menu extensions
menu :top_menu, :cost_types, {:controller => 'cost_types', :action => 'index'},
:caption => :cost_types_title, :if => Proc.new { User.current.admin? }
# menu :top_menu, :cost_report, {:controller => 'cost_report', :action => 'index'},
# :caption => :cost_report_title,
# :if => Proc.new {
# User.current.allowed_to?(:view_cost_objects, nil, :global => true) ||
# User.current.allowed_to?(:edit_cost_objects, nil, :global => true)
# }
menu :top_menu, :cost_reports, {:controller => 'cost_reports', :action => 'index'},
:caption => :cost_report_title,
:if => Proc.new {
User.current.allowed_to?(:view_cost_objects, nil, :global => true) ||
User.current.allowed_to?(:edit_cost_objects, nil, :global => true)
}
menu :project_menu, :cost_objects, {:controller => 'cost_objects', :action => 'index'},
:param => :project_id, :after => :new_issue, :caption => :cost_objects_title

Loading…
Cancel
Save