2013-06-12 15:59:58 +00:00
|
|
|
# Copyright (C) 2012-2013 Zammad Foundation, http://zammad-foundation.org/
|
|
|
|
|
2012-04-10 14:06:46 +00:00
|
|
|
class TicketsController < ApplicationController
|
|
|
|
before_filter :authentication_check
|
|
|
|
|
2013-01-09 18:13:29 +00:00
|
|
|
# GET /api/tickets
|
2012-04-10 14:06:46 +00:00
|
|
|
def index
|
|
|
|
@tickets = Ticket.all
|
|
|
|
|
2012-04-12 11:27:01 +00:00
|
|
|
render :json => @tickets
|
2012-04-10 14:06:46 +00:00
|
|
|
end
|
|
|
|
|
2013-01-09 18:13:29 +00:00
|
|
|
# GET /api/tickets/1
|
2012-04-10 14:06:46 +00:00
|
|
|
def show
|
2012-11-13 10:34:45 +00:00
|
|
|
@ticket = Ticket.find( params[:id] )
|
2012-04-10 14:06:46 +00:00
|
|
|
|
2012-09-04 21:28:49 +00:00
|
|
|
# permissin check
|
|
|
|
return if !ticket_permission(@ticket)
|
|
|
|
|
2012-04-12 11:27:01 +00:00
|
|
|
render :json => @ticket
|
2012-04-10 14:06:46 +00:00
|
|
|
end
|
|
|
|
|
2013-01-09 18:13:29 +00:00
|
|
|
# POST /api/tickets
|
2012-04-10 14:06:46 +00:00
|
|
|
def create
|
2012-11-13 10:34:45 +00:00
|
|
|
@ticket = Ticket.new( params[:ticket] )
|
2012-04-10 14:06:46 +00:00
|
|
|
|
2012-04-16 11:58:15 +00:00
|
|
|
# check if article is given
|
|
|
|
if !params[:article]
|
|
|
|
render :json => 'article hash is missing', :status => :unprocessable_entity
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
# create ticket
|
|
|
|
if !@ticket.save
|
2012-04-12 11:27:01 +00:00
|
|
|
render :json => @ticket.errors, :status => :unprocessable_entity
|
2012-04-16 11:58:15 +00:00
|
|
|
return
|
|
|
|
end
|
2012-10-02 05:46:08 +00:00
|
|
|
|
2012-11-18 11:06:55 +00:00
|
|
|
# create tags if given
|
|
|
|
if params[:tags] && !params[:tags].empty?
|
|
|
|
tags = params[:tags].split /,/
|
|
|
|
tags.each {|tag|
|
|
|
|
Tag.tag_add(
|
|
|
|
:object => 'Ticket',
|
|
|
|
:o_id => @ticket.id,
|
|
|
|
:item => tag,
|
|
|
|
:created_by_id => current_user.id,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2012-04-16 11:58:15 +00:00
|
|
|
# create article if given
|
|
|
|
if params[:article]
|
2012-12-02 10:18:55 +00:00
|
|
|
form_id = params[:article][:form_id]
|
|
|
|
params[:article].delete(:form_id)
|
|
|
|
@article = Ticket::Article.new( params[:article] )
|
2012-04-16 11:58:15 +00:00
|
|
|
@article.ticket_id = @ticket.id
|
2012-10-02 05:46:08 +00:00
|
|
|
|
2012-04-16 11:58:15 +00:00
|
|
|
# find attachments in upload cache
|
2012-12-02 10:18:55 +00:00
|
|
|
if form_id
|
|
|
|
@article['attachments'] = Store.list(
|
|
|
|
:object => 'UploadCache',
|
|
|
|
:o_id => form_id,
|
|
|
|
)
|
|
|
|
end
|
2012-04-16 11:58:15 +00:00
|
|
|
if !@article.save
|
|
|
|
render :json => @article.errors, :status => :unprocessable_entity
|
|
|
|
return
|
|
|
|
end
|
2012-12-02 10:18:55 +00:00
|
|
|
|
2012-04-16 11:58:15 +00:00
|
|
|
# remove attachments from upload cache
|
2012-12-02 10:18:55 +00:00
|
|
|
if params[:form_id]
|
|
|
|
Store.remove(
|
|
|
|
:object => 'UploadCache',
|
|
|
|
:o_id => form_id,
|
|
|
|
)
|
|
|
|
end
|
2012-04-10 14:06:46 +00:00
|
|
|
end
|
2012-04-16 12:56:04 +00:00
|
|
|
|
2012-04-16 11:58:15 +00:00
|
|
|
render :json => @ticket, :status => :created
|
2012-04-10 14:06:46 +00:00
|
|
|
end
|
|
|
|
|
2013-01-09 18:13:29 +00:00
|
|
|
# PUT /api/tickets/1
|
2012-04-10 14:06:46 +00:00
|
|
|
def update
|
|
|
|
@ticket = Ticket.find(params[:id])
|
|
|
|
|
2012-09-04 21:28:49 +00:00
|
|
|
# permissin check
|
|
|
|
return if !ticket_permission(@ticket)
|
|
|
|
|
2012-11-13 10:34:45 +00:00
|
|
|
if @ticket.update_attributes( params[:ticket] )
|
2012-04-12 11:27:01 +00:00
|
|
|
render :json => @ticket, :status => :ok
|
|
|
|
else
|
|
|
|
render :json => @ticket.errors, :status => :unprocessable_entity
|
2012-04-10 14:06:46 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2013-01-09 18:13:29 +00:00
|
|
|
# DELETE /api/tickets/1
|
2012-04-10 14:06:46 +00:00
|
|
|
def destroy
|
2012-11-13 10:34:45 +00:00
|
|
|
@ticket = Ticket.find( params[:id] )
|
2012-09-04 21:28:49 +00:00
|
|
|
|
|
|
|
# permissin check
|
|
|
|
return if !ticket_permission(@ticket)
|
|
|
|
|
2012-04-10 14:06:46 +00:00
|
|
|
@ticket.destroy
|
|
|
|
|
2012-04-12 11:27:01 +00:00
|
|
|
head :ok
|
2012-04-10 14:06:46 +00:00
|
|
|
end
|
2012-09-20 12:08:02 +00:00
|
|
|
|
2013-01-09 18:13:29 +00:00
|
|
|
# GET /api/ticket_customer
|
|
|
|
# GET /api/tickets_customer
|
2012-09-20 12:08:02 +00:00
|
|
|
def ticket_customer
|
2012-10-02 05:46:08 +00:00
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
# get closed/open states
|
|
|
|
ticket_state_list_open = Ticket::State.where(
|
2013-01-01 23:35:46 +00:00
|
|
|
:state_type_id => Ticket::StateType.where( :name => ['new','open', 'pending reminder', 'pending action'] )
|
2012-09-20 12:08:02 +00:00
|
|
|
)
|
|
|
|
ticket_state_list_closed = Ticket::State.where(
|
2013-01-01 23:35:46 +00:00
|
|
|
:state_type_id => Ticket::StateType.where( :name => ['closed'] )
|
2012-09-20 12:08:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
# get tickets
|
|
|
|
tickets_open = Ticket.where(
|
|
|
|
:customer_id => params[:customer_id],
|
|
|
|
:ticket_state_id => ticket_state_list_open
|
|
|
|
).limit(15).order('created_at DESC')
|
|
|
|
|
|
|
|
tickets_closed = Ticket.where(
|
|
|
|
:customer_id => params[:customer_id],
|
|
|
|
:ticket_state_id => ticket_state_list_closed
|
|
|
|
).limit(15).order('created_at DESC')
|
|
|
|
|
|
|
|
# return result
|
|
|
|
render :json => {
|
|
|
|
:tickets => {
|
|
|
|
:open => tickets_open,
|
|
|
|
:closed => tickets_closed
|
|
|
|
}
|
2013-06-12 15:59:58 +00:00
|
|
|
# :users => users,
|
2012-09-20 12:08:02 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2013-01-09 18:13:29 +00:00
|
|
|
# GET /api/ticket_history/1
|
2012-09-20 12:08:02 +00:00
|
|
|
def ticket_history
|
|
|
|
|
|
|
|
# get ticket data
|
2012-10-02 05:46:08 +00:00
|
|
|
ticket = Ticket.find( params[:id] )
|
2012-09-20 12:08:02 +00:00
|
|
|
|
|
|
|
# permissin check
|
2012-10-02 05:46:08 +00:00
|
|
|
return if !ticket_permission( ticket )
|
2012-09-20 12:08:02 +00:00
|
|
|
|
|
|
|
# get history of ticket
|
2013-06-04 12:52:56 +00:00
|
|
|
history = History.list( 'Ticket', params[:id], 'Ticket::Article' )
|
2012-09-20 12:08:02 +00:00
|
|
|
|
|
|
|
# get related users
|
|
|
|
users = {}
|
2012-10-05 07:10:14 +00:00
|
|
|
users[ ticket.owner_id ] = User.user_data_full( ticket.owner_id )
|
|
|
|
users[ ticket.customer_id ] = User.user_data_full( ticket.customer_id )
|
2012-09-20 12:08:02 +00:00
|
|
|
history.each do |item|
|
|
|
|
users[ item['created_by_id'] ] = User.user_data_full( item['created_by_id'] )
|
|
|
|
if item['history_object'] == 'Ticket::Article'
|
|
|
|
item['type'] = 'Article ' + item['type'].to_s
|
|
|
|
else
|
|
|
|
item['type'] = 'Ticket ' + item['type'].to_s
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# fetch meta relations
|
|
|
|
history_objects = History::Object.all()
|
|
|
|
history_types = History::Type.all()
|
|
|
|
history_attributes = History::Attribute.all()
|
|
|
|
|
|
|
|
# return result
|
|
|
|
render :json => {
|
|
|
|
:ticket => ticket,
|
|
|
|
:users => users,
|
|
|
|
:history => history,
|
|
|
|
:history_objects => history_objects,
|
|
|
|
:history_types => history_types,
|
|
|
|
:history_attributes => history_attributes
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2013-01-09 18:13:29 +00:00
|
|
|
# GET /api/ticket_merge_list/1
|
2012-10-18 19:23:05 +00:00
|
|
|
def ticket_merge_list
|
|
|
|
|
|
|
|
# get closed/open states
|
|
|
|
ticket_states = Ticket::State.where(
|
2013-01-01 23:35:46 +00:00
|
|
|
:state_type_id => Ticket::StateType.where( :name => ['new','open', 'pending reminder', 'pending action', 'closed'] )
|
2012-10-18 19:23:05 +00:00
|
|
|
)
|
|
|
|
ticket = Ticket.find( params[:ticket_id] )
|
2012-10-22 15:38:30 +00:00
|
|
|
ticket_list = Ticket.where( :customer_id => ticket.customer_id, :ticket_state_id => ticket_states )
|
2013-06-12 15:59:58 +00:00
|
|
|
.where( 'id != ?', [ ticket.id ] )
|
|
|
|
.order('created_at DESC')
|
|
|
|
.limit(6)
|
2012-10-18 19:23:05 +00:00
|
|
|
|
|
|
|
# get related users
|
|
|
|
users = {}
|
|
|
|
tickets = []
|
|
|
|
ticket_list.each {|ticket|
|
2013-01-01 20:29:26 +00:00
|
|
|
data = Ticket.lookup( :id => ticket.id )
|
2012-10-18 19:23:05 +00:00
|
|
|
tickets.push data
|
|
|
|
if !users[ data['owner_id'] ]
|
|
|
|
users[ data['owner_id'] ] = User.user_data_full( data['owner_id'] )
|
|
|
|
end
|
|
|
|
if !users[ data['customer_id'] ]
|
|
|
|
users[ data['customer_id'] ] = User.user_data_full( data['customer_id'] )
|
|
|
|
end
|
|
|
|
if !users[ data['created_by_id'] ]
|
|
|
|
users[ data['created_by_id'] ] = User.user_data_full( data['created_by_id'] )
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
2013-05-21 23:00:20 +00:00
|
|
|
recent_viewed = RecentView.list_fulldata( current_user, 8 )
|
2012-10-18 19:23:05 +00:00
|
|
|
|
|
|
|
# return result
|
|
|
|
render :json => {
|
|
|
|
:customer => {
|
|
|
|
:tickets => tickets,
|
|
|
|
:users => users,
|
|
|
|
},
|
|
|
|
:recent => recent_viewed
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
# GET /ticket_merge/1/1
|
|
|
|
def ticket_merge
|
|
|
|
|
|
|
|
# check master ticket
|
|
|
|
ticket_master = Ticket.where( :number => params[:master_ticket_number] ).first
|
|
|
|
if !ticket_master
|
|
|
|
render :json => {
|
|
|
|
:result => 'faild',
|
|
|
|
:message => 'No such master ticket number!',
|
|
|
|
}
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
# permissin check
|
|
|
|
return if !ticket_permission(ticket_master)
|
|
|
|
|
|
|
|
# check slave ticket
|
|
|
|
ticket_slave = Ticket.where( :id => params[:slave_ticket_id] ).first
|
|
|
|
if !ticket_slave
|
|
|
|
render :json => {
|
|
|
|
:result => 'faild',
|
|
|
|
:message => 'No such slave ticket!',
|
|
|
|
}
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
|
|
|
# permissin check
|
2012-10-02 05:46:08 +00:00
|
|
|
return if !ticket_permission( ticket_slave )
|
2012-09-20 12:08:02 +00:00
|
|
|
|
|
|
|
# check diffetent ticket ids
|
|
|
|
if ticket_slave.id == ticket_master.id
|
|
|
|
render :json => {
|
|
|
|
:result => 'faild',
|
|
|
|
:message => 'Can\'t merge ticket with it self!',
|
|
|
|
}
|
|
|
|
return
|
|
|
|
end
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
# merge ticket
|
|
|
|
success = ticket_slave.merge_to(
|
|
|
|
{
|
|
|
|
:ticket_id => ticket_master.id,
|
|
|
|
:created_by_id => current_user.id,
|
2013-06-12 15:59:58 +00:00
|
|
|
}
|
|
|
|
)
|
2012-09-20 12:08:02 +00:00
|
|
|
|
|
|
|
# return result
|
|
|
|
render :json => {
|
|
|
|
:result => 'success',
|
|
|
|
:master_ticket => ticket_master.attributes,
|
|
|
|
:slave_ticket => ticket_slave.attributes,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /ticket_full/1
|
|
|
|
def ticket_full
|
|
|
|
|
|
|
|
# permission check
|
2012-10-02 05:46:08 +00:00
|
|
|
ticket = Ticket.find( params[:id] )
|
|
|
|
return if !ticket_permission( ticket )
|
2012-09-20 12:08:02 +00:00
|
|
|
|
|
|
|
# get related users
|
|
|
|
users = {}
|
|
|
|
if !users[ticket.owner_id]
|
2012-10-02 05:46:08 +00:00
|
|
|
users[ticket.owner_id] = User.user_data_full( ticket.owner_id )
|
2012-09-20 12:08:02 +00:00
|
|
|
end
|
|
|
|
if !users[ticket.customer_id]
|
2012-10-02 05:46:08 +00:00
|
|
|
users[ticket.customer_id] = User.user_data_full( ticket.customer_id )
|
2012-09-20 12:08:02 +00:00
|
|
|
end
|
|
|
|
if !users[ticket.created_by_id]
|
2012-10-02 05:46:08 +00:00
|
|
|
users[ticket.created_by_id] = User.user_data_full( ticket.created_by_id )
|
2012-09-20 12:08:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# log object as viewed
|
2013-05-11 23:33:37 +00:00
|
|
|
if !params[:do_not_log] || params[:do_not_log].to_i == 0
|
2013-03-10 16:45:14 +00:00
|
|
|
log_view( ticket )
|
|
|
|
end
|
2012-10-02 05:46:08 +00:00
|
|
|
|
|
|
|
# get signature
|
2012-10-03 19:45:04 +00:00
|
|
|
signature = {}
|
|
|
|
if ticket.group.signature
|
|
|
|
signature = ticket.group.signature.attributes
|
|
|
|
|
|
|
|
# replace tags
|
|
|
|
signature['body'] = NotificationFactory.build(
|
2013-01-04 14:28:55 +00:00
|
|
|
:locale => current_user.locale,
|
2012-10-03 19:45:04 +00:00
|
|
|
:string => signature['body'],
|
|
|
|
:objects => {
|
|
|
|
:ticket => ticket,
|
|
|
|
:user => current_user,
|
|
|
|
}
|
|
|
|
)
|
|
|
|
end
|
2012-09-20 12:08:02 +00:00
|
|
|
|
2013-01-04 08:09:59 +00:00
|
|
|
# get attributes to update
|
|
|
|
attributes_to_change = Ticket.attributes_to_change( :user => current_user, :ticket => ticket )
|
|
|
|
|
|
|
|
attributes_to_change[:owner_id].each { |user_id|
|
|
|
|
if !users[user_id]
|
|
|
|
users[user_id] = User.user_data_full( user_id )
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes_to_change[:group_id__owner_id].each {|group_id, user_ids|
|
|
|
|
user_ids.each {|user_id|
|
|
|
|
if !users[user_id]
|
|
|
|
users[user_id] = User.user_data_full( user_id )
|
|
|
|
end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
# get related articles
|
|
|
|
ticket = ticket.attributes
|
|
|
|
ticket[:article_ids] = []
|
|
|
|
articles = Ticket::Article.where( :ticket_id => params[:id] )
|
|
|
|
|
|
|
|
# get related users
|
|
|
|
articles_used = []
|
|
|
|
articles.each {|article|
|
|
|
|
|
|
|
|
# ignore internal article if customer is requesting
|
|
|
|
next if article.internal == true && is_role('Customer')
|
|
|
|
article_tmp = article.attributes
|
|
|
|
|
|
|
|
# load article ids
|
|
|
|
ticket[:article_ids].push article_tmp['id']
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
# add attachment list to article
|
|
|
|
article_tmp['attachments'] = Store.list( :object => 'Ticket::Article', :o_id => article.id )
|
|
|
|
|
|
|
|
# remember article
|
|
|
|
articles_used.push article_tmp
|
|
|
|
|
|
|
|
# load users
|
|
|
|
if !users[article.created_by_id]
|
2012-10-02 05:46:08 +00:00
|
|
|
users[article.created_by_id] = User.user_data_full( article.created_by_id )
|
2012-09-20 12:08:02 +00:00
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
# return result
|
|
|
|
render :json => {
|
2012-10-02 05:46:08 +00:00
|
|
|
:ticket => ticket,
|
|
|
|
:articles => articles_used,
|
|
|
|
:signature => signature,
|
|
|
|
:users => users,
|
2013-01-04 08:09:59 +00:00
|
|
|
:edit_form => attributes_to_change,
|
2012-09-20 12:08:02 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
# GET /ticket_create/1
|
|
|
|
def ticket_create
|
|
|
|
|
2013-01-04 08:09:59 +00:00
|
|
|
# get attributes to update
|
|
|
|
attributes_to_change = Ticket.attributes_to_change(
|
|
|
|
:user => current_user,
|
2013-06-12 15:59:58 +00:00
|
|
|
# :ticket_id => params[:ticket_id],
|
|
|
|
# :article_id => params[:article_id]
|
2012-09-20 12:08:02 +00:00
|
|
|
)
|
|
|
|
|
2013-01-04 08:09:59 +00:00
|
|
|
users = {}
|
|
|
|
attributes_to_change[:owner_id].each { |user_id|
|
|
|
|
if !users[user_id]
|
|
|
|
users[user_id] = User.user_data_full( user_id )
|
|
|
|
end
|
|
|
|
}
|
|
|
|
|
|
|
|
attributes_to_change[:group_id__owner_id].each {|group_id, user_ids|
|
|
|
|
user_ids.each {|user_id|
|
|
|
|
if !users[user_id]
|
|
|
|
users[user_id] = User.user_data_full( user_id )
|
|
|
|
end
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
# split data
|
|
|
|
ticket = nil
|
|
|
|
articles = nil
|
|
|
|
if params[:ticket_id] && params[:article_id]
|
|
|
|
ticket = Ticket.find( params[:ticket_id] )
|
|
|
|
|
|
|
|
# get related users
|
|
|
|
if !users[ticket.owner_id]
|
2012-10-02 05:46:08 +00:00
|
|
|
users[ticket.owner_id] = User.user_data_full( ticket.owner_id )
|
2012-09-20 12:08:02 +00:00
|
|
|
end
|
|
|
|
if !users[ticket.customer_id]
|
2012-10-02 05:46:08 +00:00
|
|
|
users[ticket.customer_id] = User.user_data_full( ticket.customer_id )
|
2012-09-20 12:08:02 +00:00
|
|
|
end
|
|
|
|
if !users[ticket.created_by_id]
|
2012-10-02 05:46:08 +00:00
|
|
|
users[ticket.created_by_id] = User.user_data_full( ticket.created_by_id )
|
2012-09-20 12:08:02 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
owner_ids = []
|
|
|
|
ticket.agent_of_group.each { |user|
|
|
|
|
owner_ids.push user.id
|
|
|
|
if !users[user.id]
|
2012-10-02 05:46:08 +00:00
|
|
|
users[user.id] = User.user_data_full( user.id )
|
2012-09-20 12:08:02 +00:00
|
|
|
end
|
|
|
|
}
|
2013-01-04 08:09:59 +00:00
|
|
|
|
2012-09-20 12:08:02 +00:00
|
|
|
# get related articles
|
|
|
|
ticket[:article_ids] = [ params[:article_id] ]
|
|
|
|
|
|
|
|
article = Ticket::Article.find( params[:article_id] )
|
|
|
|
|
|
|
|
# add attachment list to article
|
|
|
|
article['attachments'] = Store.list( :object => 'Ticket::Article', :o_id => article.id )
|
|
|
|
|
|
|
|
# load users
|
|
|
|
if !users[article.created_by_id]
|
2012-10-02 05:46:08 +00:00
|
|
|
users[article.created_by_id] = User.user_data_full( article.created_by_id )
|
2012-09-20 12:08:02 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
# return result
|
|
|
|
render :json => {
|
|
|
|
:ticket => ticket,
|
|
|
|
:articles => [ article ],
|
|
|
|
:users => users,
|
2013-01-04 08:09:59 +00:00
|
|
|
:edit_form => attributes_to_change,
|
2012-09-20 12:08:02 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2012-11-14 01:05:53 +00:00
|
|
|
# GET /api/tickets/search
|
|
|
|
def search
|
2013-06-12 15:59:58 +00:00
|
|
|
|
2012-11-14 01:05:53 +00:00
|
|
|
# build result list
|
2013-05-21 22:30:09 +00:00
|
|
|
tickets = Ticket.search(
|
|
|
|
:limit => params[:limit],
|
|
|
|
:query => params[:term],
|
|
|
|
:current_user => current_user,
|
|
|
|
)
|
|
|
|
users_data = {}
|
|
|
|
ticket_result = []
|
|
|
|
tickets.each do |ticket|
|
|
|
|
ticket_result.push ticket.id
|
|
|
|
users_data[ ticket['owner_id'] ] = User.user_data_full( ticket['owner_id'] )
|
|
|
|
users_data[ ticket['customer_id'] ] = User.user_data_full( ticket['customer_id'] )
|
|
|
|
users_data[ ticket['created_by_id'] ] = User.user_data_full( ticket['created_by_id'] )
|
2012-11-14 01:05:53 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# return result
|
|
|
|
render :json => {
|
2013-05-21 22:30:09 +00:00
|
|
|
:tickets => ticket_result,
|
|
|
|
:users => users_data,
|
2012-11-14 01:05:53 +00:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2012-04-10 14:06:46 +00:00
|
|
|
end
|