2014-02-03 19:23:00 +00:00
|
|
|
# Copyright (C) 2012-2014 Zammad Foundation, http://zammad-foundation.org/
|
2015-04-27 23:19:26 +00:00
|
|
|
class Ticket::State < ApplicationModel
|
2015-07-03 17:47:23 +00:00
|
|
|
belongs_to :state_type, class_name: 'Ticket::StateType'
|
2015-04-27 23:19:26 +00:00
|
|
|
validates :name, presence: true
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2015-04-27 23:19:26 +00:00
|
|
|
latest_change_support
|
2015-02-25 20:52:14 +00:00
|
|
|
|
2013-08-06 09:23:25 +00:00
|
|
|
=begin
|
|
|
|
|
|
|
|
list tickets by customer
|
|
|
|
|
2015-09-06 23:54:47 +00:00
|
|
|
states = Ticket::State.by_category('open') # open|closed|work_on|pending_reminder
|
2013-08-06 09:23:25 +00:00
|
|
|
|
2013-08-06 09:49:56 +00:00
|
|
|
returns:
|
|
|
|
|
|
|
|
state objects
|
|
|
|
|
2013-08-06 09:23:25 +00:00
|
|
|
=end
|
|
|
|
|
2015-04-27 23:19:26 +00:00
|
|
|
def self.by_category(category)
|
|
|
|
if category == 'open'
|
|
|
|
return Ticket::State.where(
|
|
|
|
state_type_id: Ticket::StateType.where( name: ['new', 'open', 'pending reminder', 'pending action'] )
|
|
|
|
)
|
2015-09-06 23:54:47 +00:00
|
|
|
elsif category == 'pending_reminder'
|
|
|
|
return Ticket::State.where(
|
|
|
|
state_type_id: Ticket::StateType.where( name: ['pending reminder'] )
|
|
|
|
)
|
|
|
|
elsif category == 'work_on'
|
|
|
|
return Ticket::State.where(
|
|
|
|
state_type_id: Ticket::StateType.where( name: ['new', 'open'] )
|
|
|
|
)
|
2015-04-27 23:19:26 +00:00
|
|
|
elsif category == 'closed'
|
|
|
|
return Ticket::State.where(
|
|
|
|
state_type_id: Ticket::StateType.where( name: ['closed'] )
|
|
|
|
)
|
2014-02-03 19:23:00 +00:00
|
|
|
end
|
2015-05-07 11:27:07 +00:00
|
|
|
fail "Unknown category '#{category}'"
|
2015-04-27 23:19:26 +00:00
|
|
|
end
|
2013-08-06 09:49:56 +00:00
|
|
|
|
|
|
|
=begin
|
|
|
|
|
|
|
|
check if state is ignored for escalation
|
|
|
|
|
2014-06-08 22:01:20 +00:00
|
|
|
state = Ticket::State.lookup( :name => 'state name' )
|
2013-08-06 09:49:56 +00:00
|
|
|
|
2014-06-08 22:01:20 +00:00
|
|
|
result = state.ignore_escalation?
|
2013-08-06 09:49:56 +00:00
|
|
|
|
|
|
|
returns:
|
|
|
|
|
|
|
|
true/false
|
|
|
|
|
|
|
|
=end
|
|
|
|
|
2015-04-27 23:19:26 +00:00
|
|
|
def ignore_escalation?
|
2015-05-07 07:23:16 +00:00
|
|
|
ignore_escalation = %w(removed closed merged)
|
2015-05-07 12:10:38 +00:00
|
|
|
return true if ignore_escalation.include?( name )
|
2015-04-27 23:19:26 +00:00
|
|
|
false
|
2013-08-06 09:49:56 +00:00
|
|
|
end
|
2013-06-12 15:59:58 +00:00
|
|
|
end
|