QueueService.pm
6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
# --
# Kernel/Modules/QueueService.pm - frontend module
#
# Copyright (C) 2014 - SeTIC - UFSC - http://setic.ufsc.br/
# Version 01/06/2015 - Adjusts for OTRS 4
#
# Autor: Carlos Rebelato, Rodrigo Gonçalves
# Data.: 19/02/2014 - Versão inicial
#
package Kernel::Modules::QueueService;
use strict;
use warnings;
use Data::Dumper;
require Kernel::System::QueueService;
require Kernel::System::Service;
require Kernel::System::Queue;
our @ObjectDependencies = (
"Kernel::System::Web::Request", # Old ParamObject
"Kernel::System::DB",
"Kernel::System::Ticket",
"Kernel::Output::HTML::Layout", # Old LayoutObject
"Kernel::System::Log",
"Kernel::System::Queue",
"Kernel::Config",
"Kernel::System::Encode",
"Kernel::System::Main",
"Kernel::System::QueueService", # Ask direct to manager
"Kernel::System::Service" # Ask direct to manager
);
sub new {
my ( $Type, %Param ) = @_;
# allocate new hash for object
my $Self = {%Param};
bless( $Self, $Type );
return $Self;
}
sub Run {
my ( $Self, %Param ) = @_;
my $ParamObject = $Kernel::OM->Get("Kernel::System::Web::Request");
my $SubAction = $ParamObject->GetParam( Param => "Subaction" );
if ( $SubAction eq "ServiceEdit" ) {
return $Self->ShowChangeService( ID => $ParamObject->GetParam( Param => "ID" ) );
}
elsif ( $SubAction eq "QueueEdit" ) {
return $Self->ShowChangeQueue( ID => $ParamObject->GetParam( Param => "ID" ) );
}
elsif ( $SubAction eq "ChangeService" ) {
$Self->ChangeService();
return $Self->ShowOverview();
}
elsif ( $SubAction eq "ChangeQueue" ) {
$Self->ChangeQueue();
return $Self->ShowOverview();
}
else {
return $Self->ShowOverview();
}
}
sub ShowOverview() {
my ( $Self, %Param ) = @_;
my %Data = ();
my %Queues = $Kernel::OM->Get("Kernel::System::Queue")->QueueList( Valid => 1 );
my %Services = $Kernel::OM->Get("Kernel::System::Service")->ServiceList( UserID => 1 );
my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
foreach my $service ( sort { uc( $Services{$a} ) cmp uc( $Services{$b} ) } keys %Services ) {
$LayoutObject->Block(
Name => 'ListService',
Data => {
ServiceID => $service,
ServiceName => $Services{$service},
}
);
}
foreach my $queue ( sort { uc( $Queues{$a} ) cmp uc( $Queues{$b} ) } keys %Queues ) {
$LayoutObject->Block(
Name => 'ListQueue',
Data => {
QueueID => $queue,
QueueName => $Queues{$queue},
}
);
}
my $Output = $LayoutObject->Header( Title => $LayoutObject->{LanguageObject}->Get("Services per queue") );
$Output .= $LayoutObject->NavigationBar();
$Output .= $LayoutObject->Output(
Data => \%Data,
TemplateFile => 'QueueService'
);
$Output .= $LayoutObject->Footer();
return $Output;
}
sub ShowChangeService() {
my ( $Self, %Param ) = @_;
my %Data = ();
my %Service = $Kernel::OM->Get("Kernel::System::Service")->ServiceGet( ServiceID => $Param{ID}, UserID => 1 );
my %QueuesService = $Kernel::OM->Get("Kernel::System::QueueService")->GetQueueList( ServiceID => $Param{ID} );
my %Queues = $Kernel::OM->Get("Kernel::System::Queue")->QueueList( Valid => 1 );
my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
$Data{Type} = "Queue";
$Data{Filter} = "Service";
$Data{VisibleNeType} = "Service";
$Data{Name} = $Service{Name};
$Data{ID} = $Service{ServiceID};
$LayoutObject->Block(
Name => 'ChangeHeader',
Data => \%Data
);
foreach my $queue ( sort { uc( $Queues{$a} ) cmp uc( $Queues{$b} ) } keys %Queues ) {
$LayoutObject->Block(
Name => 'ChangeRow',
Data => {
Type => "Queue",
ID => $queue,
Name => $Queues{$queue},
Selected => ( $QueuesService{$queue} ? 'checked="checked"' : '' )
}
);
}
my $Output =
$LayoutObject->Header( Title => $LayoutObject->{LanguageObject}->Get("Services per queue") );
$Output .= $LayoutObject->NavigationBar();
$Output .= $LayoutObject->Output(
Data => \%Data,
TemplateFile => 'QueueServiceChange'
);
$Output .= $LayoutObject->Footer();
return $Output;
}
sub ShowChangeQueue() {
my ( $Self, %Param ) = @_;
my %Data = ();
my %Queue = $Kernel::OM->Get("Kernel::System::Queue")->QueueGet( ID => $Param{ID} );
my %ServicesQueue = $Kernel::OM->Get("Kernel::System::QueueService")->GetServiceList( QueueID => $Param{ID} );
my %Services = $Kernel::OM->Get("Kernel::System::Service")->ServiceList( UserID => 1 );
my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
$Data{Type} = "Service";
$Data{Filter} = "Queue";
$Data{VisibleNeType} = "Queue";
$Data{Name} = $Queue{Name};
$Data{ID} = $Queue{QueueID};
$LayoutObject->Block(
Name => 'ChangeHeader',
Data => \%Data
);
foreach my $service ( sort { uc( $Services{$a} ) cmp uc( $Services{$b} ) } keys %Services ) {
$LayoutObject->Block(
Name => 'ChangeRow',
Data => {
Type => "Service",
ID => $service,
Name => $Services{$service},
Selected => ( $ServicesQueue{$service} ? 'checked="checked"' : '' )
}
);
}
my $Output =
$LayoutObject->Header( Title => $LayoutObject->{LanguageObject}->Get("Services per queue") );
$Output .= $LayoutObject->NavigationBar();
$Output .= $LayoutObject->Output(
Data => \%Data,
TemplateFile => 'QueueServiceChange'
);
$Output .= $LayoutObject->Footer();
return $Output;
}
sub ChangeService() {
my ( $Self, %Param ) = @_;
my @queueIDs = $Kernel::OM->Get("Kernel::System::Web::Request")->GetArray( Param => 'Queue' );
my $id = $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => 'ID' );
$Kernel::OM->Get("Kernel::System::QueueService")->SetServiceQueues(ServiceID => $id, Queues => \@queueIDs);
}
sub ChangeQueue() {
my ( $Self, %Param ) = @_;
my @serviceIDs = $Kernel::OM->Get("Kernel::System::Web::Request")->GetArray( Param => 'Service' );
my $id = $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => 'ID' );
$Kernel::OM->Get("Kernel::System::QueueService")->SetQueueServices(QueueID => $id, Services => \@serviceIDs);
}