Reset ticket state new (set it to open) on first communication with customer.

This commit is contained in:
Martin Edenhofer 2013-01-04 09:10:36 +01:00
parent 99b4836921
commit 314c545671
2 changed files with 35 additions and 1 deletions

View file

@ -0,0 +1,33 @@
class Observer::Ticket::ResetNewState < ActiveRecord::Observer
observe 'ticket::_article'
def after_create(record)
# puts 'check reset new state'
# return if we run import mode
return if Setting.get('import_mode')
# if article in internal
return true if record.internal
# if sender is agent
return true if Ticket::Article::Sender.lookup( :id => record.ticket_article_sender_id ).name != 'Agent'
# if article is a message to customer
return true if !Ticket::Article::Type.lookup( :id => record.ticket_article_type_id ).communication
# if current ticket state is still new
ticket = Ticket.lookup( :id => record.ticket_id )
return true if ticket.ticket_state.state_type.name != 'new'
# TODO: add config option to state managment in UI
state = Ticket::State.lookup( :name => 'open' )
return if !state
# set ticket to open
ticket.ticket_state_id = state.id
# save ticket
ticket.save
end
end

View file

@ -39,7 +39,8 @@ module Zammad
'observer::_ticket::_article::_communicate_facebook',
'observer::_ticket::_article::_communicate_twitter',
'observer::_ticket::_notification',
'observer::_tag::_ticket_history'
'observer::_tag::_ticket_history',
'observer::_ticket::_reset_new_state'
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.