Show also recipients in ticket history.

This commit is contained in:
Martin Edenhofer 2012-08-10 09:42:16 +02:00
parent 0186c8f70d
commit 480abed922
3 changed files with 51 additions and 10 deletions

View file

@ -6,22 +6,38 @@
<% open = false %>
<% for object in @objects: %>
<% if lasttime isnt object['created_at']: %>
<% object['history_object_display'] = object['history_object'] %>
<% if object['history_object'] is 'Ticket::Article': %>
<% object['history_object_display'] = 'Article' %>
<% end %>
<% if lasttime isnt object['created_at'] || last_user isnt object['created_by_id']: %>
<% if open: %>
</ul>
<hr>
<% end %>
<% open = true %>
<% last_user = object['created_by_id'] %>
<% lasttime = object['created_at'] %>
<span class="user-data" data-id="<%= object['created_by']['id'] %>"><%= object['created_by']['realname'] %></span> - <%= object['created_at'] %> - <%= object['humanTime'] %>
<ul>
<% end %>
<li><%= object['history_type'] %> <%= object['history_object'] %> <% if object['history_attribute']: %>"<%= object['history_attribute'] %>"<% end %>
<% if object['value_from']: %>
<%- T('from') %> "<%= object['value_from'] %>"
<% end %>
<% if object['value_to']: %>
<%- T('to') %> "<%= object['value_to'] %>"
<li>
<% if ( object['history_type'] is 'notification' || object['history_type'] is 'email' ): %>
<%= object['history_type'] %>
<% if object['value_from']: %>
"<%= object['value_from'] %>" <%- T('sent to') %>
<% end %>
<% if object['value_to']: %>
"<%= object['value_to'] %>"
<% end %>
<% else: %>
<%= object['history_type'] %> <%= object['history_object_display'] %> <% if object['history_attribute']: %>"<%= object['history_attribute'] %>"<% end %>
<% if object['value_from']: %>
<%- T('from') %> "<%= object['value_from'] %>"
<% end %>
<% if object['value_to']: %>
<%- T('to') %> "<%= object['value_to'] %>"
<% end %>
<% end %>
</li>
<% end %>

View file

@ -69,7 +69,7 @@ class History < ActiveRecord::Base
if !related_history_object
history = History.where( :history_object_id => History::Object.where( :name => requested_object ) ).
where( :o_id => requested_object_id ).
where( :history_type_id => History::Type.where( :name => ['created', 'updated', 'notification'] ) ).
where( :history_type_id => History::Type.where( :name => ['created', 'updated', 'notification', 'email'] ) ).
order('created_at ASC, id ASC')
else
history = History.where(
@ -78,7 +78,7 @@ class History < ActiveRecord::Base
requested_object_id,
History::Object.where( :name => related_history_object ).first.id,
requested_object_id,
History::Type.where( :name => ['created', 'updated', 'notification'] )
History::Type.where( :name => ['created', 'updated', 'notification', 'email'] )
).
order('created_at ASC, id ASC')
end

View file

@ -15,7 +15,8 @@ class Ticket::Article < ApplicationModel
# if sender is customer, do not change anything
sender = Ticket::Article::Sender.where( :id => self.ticket_article_sender_id ).first
return if sender == nil || sender['name'] == 'Customer'
return if sender == nil
return if sender['name'] == 'Customer'
type = Ticket::Article::Type.where( :id => self.ticket_article_type_id ).first
ticket = Ticket.find(self.ticket_id)
@ -139,6 +140,30 @@ class Ticket::Article < ApplicationModel
:filename => "ticket-#{ticket.number}-#{self.id}.eml",
:preferences => {}
)
# add history record
recipient_list = ''
[:to, :cc].each { |key|
if self[key] && self[key] != ''
if recipient_list != ''
recipient_list += ','
end
recipient_list += self[key]
end
}
if recipient_list != ''
History.history_create(
:o_id => self.id,
:history_type => 'email',
:history_object => 'Ticket::Article',
:related_o_id => ticket.id,
:related_history_object => 'Ticket',
:value_from => self.subject,
:value_to => recipient_list,
:created_by_id => self.created_by_id,
)
end
end
end