Reverted part on r520

git-svn-id: https://dev.finn.de/svn/cockpit/trunk@525 7926756e-e54e-46e6-9721-ed318f58905e
pull/6827/head
hjust 15 years ago
parent 1df98d15f2
commit 228028b118
  1. 32
      app/models/cost_query.rb

@ -103,28 +103,6 @@ class CostQuery < ActiveRecord::Base
self.group_by ||= {}
end
def display_time_entries
# read_attribute("display_time_entries") && (
!self.filters || !self.filters.any? do |f|
f["enabled"] == "1" && f["scope"] == "costs" && f["column_name"] == "cost_type_id" && (
(f["operator"] == "!" && f["values"].include?("")) ||
(f["operator"] == "=" && !f["values"].include?(""))
)
end
# )
end
def display_cost_entries
# read_attribute("display_cost_entries") && (
!self.filters || !self.filters.any? do |f|
f["enabled"] == "1" && f["scope"] == "costs" && f["column_name"] == "cost_type_id" && (
(f["operator"] == "=" && f["values"].all? {|v| v == ""})
)
end
# )
end
def self.operators
# These are the operators used by filter types.
@ -179,7 +157,7 @@ class CostQuery < ActiveRecord::Base
@available_filters = {
:costs => {
"cost_type_id" => { :type => :list, :order => 2, :applies => [:cost_entries], :flags => [], :db_table => CostType.table_name, :db_field => "id", :values => [[l(:field_labor_costs), ""]] + CostType.find(:all, :order => 'name').collect{|s| [s.name, s.id.to_s] }},
"cost_type_id" => { :type => :list_optional, :order => 2, :applies => [:cost_entries], :flags => [], :db_table => CostType.table_name, :db_field => "id", :values => CostType.find(:all, :order => 'name').collect{|s| [s.name, s.id.to_s] }},
"activity_id" => { :type => :list_optional, :order => 3, :applies => [:time_entries], :flags => [], :db_table => TimeEntryActivity.table_name, :db_field => "id", :values => TimeEntryActivity.find(:all, :order => 'position').collect{|s| [s.name, s.id.to_s] }},
"created_on" => { :type => :date_exact, :applies => [:time_entries, :cost_entries], :flags => [], :order => 4 },
"updated_on" => { :type => :date_exact, :applies => [:time_entries, :cost_entries], :flags => [], :order => 5 },
@ -253,10 +231,6 @@ class CostQuery < ActiveRecord::Base
return match.blank? ? nil : match[0]
end
def clean_filters
end
MAGIC_GROUP_KEYS = [:block, :time, :display, :db_field, :other_group]
def self.grouping_column(*names, &block)
@ -671,9 +645,9 @@ private
sql = ''
case operator
when "="
sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| val.present? ? "'#{connection.quote_string(val)}'" : "NULL"}.join(",") + ")" unless value.blank?
sql = "#{db_table}.#{db_field} IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + ")" unless value.blank?
when "!"
sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + value.collect{|val| val.present? ? "'#{connection.quote_string(val)}'" : "NULL"}.join(",") + "))"
sql = "(#{db_table}.#{db_field} IS NULL OR #{db_table}.#{db_field} NOT IN (" + value.collect{|val| "'#{connection.quote_string(val)}'"}.join(",") + "))"
when "!*"
sql = "#{db_table}.#{db_field} IS NULL"
sql << " OR #{db_table}.#{db_field} = ''" if is_custom_filter

Loading…
Cancel
Save