Commit 6f814e2e8538cc7456d8327de9e2a7f5bd04ccd5
0 parents
Exists in
master
Inclusao de modulo
Showing
9 changed files
with
687 additions
and
0 deletions
Show diff stats
1 | +++ a/.project | |
... | ... | @@ -0,0 +1,18 @@ |
1 | +<?xml version="1.0" encoding="UTF-8"?> | |
2 | +<projectDescription> | |
3 | + <name>otrs-queue-service</name> | |
4 | + <comment></comment> | |
5 | + <projects> | |
6 | + <project>otrs</project> | |
7 | + </projects> | |
8 | + <buildSpec> | |
9 | + <buildCommand> | |
10 | + <name>org.epic.perleditor.perlbuilder</name> | |
11 | + <arguments> | |
12 | + </arguments> | |
13 | + </buildCommand> | |
14 | + </buildSpec> | |
15 | + <natures> | |
16 | + <nature>org.epic.perleditor.perlnature</nature> | |
17 | + </natures> | |
18 | +</projectDescription> | ... | ... |
1 | +++ a/Kernel/Config/Files/QueueService.xml | |
... | ... | @@ -0,0 +1,24 @@ |
1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
2 | +<otrs_config init="Application" version="1.0"> | |
3 | + | |
4 | + <ConfigItem Name="Frontend::Module###QueueService" Required="0" Valid="1"> | |
5 | + <Description Translatable="1">Frontend module registration for the service per queue</Description> | |
6 | + <Group>Ticket</Group> | |
7 | + <SubGroup>Frontend::Admin::ModuleRegistration</SubGroup> | |
8 | + <Setting> | |
9 | + <FrontendModuleReg> | |
10 | + <Group>admin</Group> | |
11 | + <Description>Admin</Description> | |
12 | + <Title Translatable="1">Services per queue</Title> | |
13 | + <NavBarName>Admin</NavBarName> | |
14 | + <NavBarModule> | |
15 | + <Module>Kernel::Output::HTML::NavBarModuleAdmin</Module> | |
16 | + <Name Translatable="1">Service per queue</Name> | |
17 | + <Description Translatable="1">Create and manage services per queue</Description> | |
18 | + <Block>Ticket</Block> | |
19 | + <Prio>900</Prio> | |
20 | + </NavBarModule> | |
21 | + </FrontendModuleReg> | |
22 | + </Setting> | |
23 | + </ConfigItem> | |
24 | +</otrs_config> | ... | ... |
1 | +++ a/Kernel/Language/pt_BR_QueueService.pm | |
... | ... | @@ -0,0 +1,22 @@ |
1 | +# -- | |
2 | +# Kernel/Modules/pt_BR_NewTicketWizard.pm - frontend module for creating custom new ticket interfaces | |
3 | +# Translations | |
4 | +# | |
5 | +# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br) | |
6 | +# -- | |
7 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
8 | +# the enclosed file COPYING for license information (AGPL). If you | |
9 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
10 | +# -- | |
11 | +package Kernel::Language::pt_BR_NewTicketWizard; | |
12 | + | |
13 | +use strict; | |
14 | +use warnings; | |
15 | + | |
16 | +sub Data { | |
17 | + my $Self = shift; | |
18 | + | |
19 | + $Self->{Translation}->{'Services per queue'} = 'Serviços por fila'; | |
20 | + return 1; | |
21 | +} | |
22 | +1; | |
0 | 23 | \ No newline at end of file | ... | ... |
1 | +++ a/Kernel/Modules/QueueService.pm | |
... | ... | @@ -0,0 +1,209 @@ |
1 | +# -- | |
2 | +# Kernel/Modules/QueueService.pm - frontend module | |
3 | +# Copyright (C) (2014) (Rodrigo Gonçalves) (rodrigo.g@ufsc.br) | |
4 | +# -- | |
5 | +# $Id: writing-otrs-application.xml,v 1.1 2010/08/13 08:59:28 mg Exp $ | |
6 | +# -- | |
7 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
8 | +# the enclosed file COPYING for license information (AGPL). If you | |
9 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
10 | +# -- | |
11 | +# Autor: Carlos Rebelato | |
12 | +# Data.: 19/02/2014 - Versão inicial | |
13 | +# | |
14 | +package Kernel::Modules::QueueService; | |
15 | + | |
16 | +use strict; | |
17 | +use warnings; | |
18 | +use Data::Dumper; | |
19 | +require Kernel::System::QueueService; | |
20 | +require Kernel::System::Service; | |
21 | +require Kernel::System::Queue; | |
22 | + | |
23 | +sub new { | |
24 | + my ( $Type, %Param ) = @_; | |
25 | + | |
26 | + # allocate new hash for object | |
27 | + my $Self = {%Param}; | |
28 | + bless( $Self, $Type ); | |
29 | + | |
30 | + # check needed objects | |
31 | + for ( | |
32 | + qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject EncodeObject MainObject) | |
33 | + ) | |
34 | + { | |
35 | + if ( !$Self->{$_} ) { | |
36 | + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); | |
37 | + } | |
38 | + } | |
39 | + | |
40 | + # create needed objects | |
41 | + $Self->{QueueServiceObject} = Kernel::System::QueueService->new(%Param); | |
42 | + $Self->{ServiceObject} = Kernel::System::Service->new(%Param); | |
43 | + | |
44 | + return $Self; | |
45 | +} | |
46 | + | |
47 | +sub Run { | |
48 | + my ( $Self, %Param ) = @_; | |
49 | + | |
50 | + my $SubAction = $Self->{ParamObject}->GetParam( Param => "Subaction" ); | |
51 | + | |
52 | + if ( $SubAction eq "ServiceEdit" ) { | |
53 | + return $Self->ShowChangeService( ID => $Self->{ParamObject}->GetParam( Param => "ID" ) ); | |
54 | + } | |
55 | + elsif ( $SubAction eq "QueueEdit" ) { | |
56 | + return $Self->ShowChangeQueue( ID => $Self->{ParamObject}->GetParam( Param => "ID" ) ); | |
57 | + } | |
58 | + elsif ( $SubAction eq "ChangeService" ) { | |
59 | + $Self->ChangeService(); | |
60 | + return $Self->ShowOverview(); | |
61 | + } | |
62 | + elsif ( $SubAction eq "ChangeQueue" ) { | |
63 | + $Self->ChangeQueue(); | |
64 | + return $Self->ShowOverview(); | |
65 | + } | |
66 | + else { | |
67 | + return $Self->ShowOverview(); | |
68 | + } | |
69 | +} | |
70 | + | |
71 | +sub ShowOverview() { | |
72 | + my ( $Self, %Param ) = @_; | |
73 | + my %Data = (); | |
74 | + | |
75 | + my %Queues = $Self->{QueueObject}->QueueList( Valid => 1 ); | |
76 | + my %Services = $Self->{ServiceObject}->ServiceList( UserID => 1 ); | |
77 | + | |
78 | + foreach my $service ( sort { uc( $Services{$a} ) cmp uc( $Services{$b} ) } keys %Services ) { | |
79 | + $Self->{LayoutObject}->Block( | |
80 | + Name => 'ListService', | |
81 | + Data => { | |
82 | + ServiceID => $service, | |
83 | + ServiceName => $Services{$service}, | |
84 | + } | |
85 | + ); | |
86 | + } | |
87 | + | |
88 | + foreach my $queue ( sort { uc( $Queues{$a} ) cmp uc( $Queues{$b} ) } keys %Queues ) { | |
89 | + $Self->{LayoutObject}->Block( | |
90 | + Name => 'ListQueue', | |
91 | + Data => { | |
92 | + QueueID => $queue, | |
93 | + QueueName => $Queues{$queue}, | |
94 | + } | |
95 | + ); | |
96 | + } | |
97 | + | |
98 | + my $Output = | |
99 | + $Self->{LayoutObject}->Header( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Services per queue") ); | |
100 | + $Output .= $Self->{LayoutObject}->NavigationBar(); | |
101 | + $Output .= $Self->{LayoutObject}->Output( | |
102 | + Data => \%Data, | |
103 | + TemplateFile => 'QueueService' | |
104 | + ); | |
105 | + | |
106 | + $Output .= $Self->{LayoutObject}->Footer(); | |
107 | + return $Output; | |
108 | +} | |
109 | + | |
110 | +sub ShowChangeService() { | |
111 | + my ( $Self, %Param ) = @_; | |
112 | + my %Data = (); | |
113 | + my %Service = $Self->{ServiceObject}->ServiceGet( ServiceID => $Param{ID}, UserID => 1 ); | |
114 | + my %QueuesService = $Self->{QueueServiceObject}->GetQueueList( ServiceID => $Param{ID} ); | |
115 | + my %Queues = $Self->{QueueObject}->QueueList( Valid => 1 ); | |
116 | + | |
117 | + $Data{Type} = "Queue"; | |
118 | + $Data{Filter} = "Service"; | |
119 | + $Data{VisibleNeType} = "Service"; | |
120 | + $Data{Name} = $Service{Name}; | |
121 | + $Data{ID} = $Service{ServiceID}; | |
122 | + | |
123 | + $Self->{LayoutObject}->Block( | |
124 | + Name => 'ChangeHeader', | |
125 | + Data => \%Data | |
126 | + ); | |
127 | + | |
128 | + foreach my $queue ( sort { uc( $Queues{$a} ) cmp uc( $Queues{$b} ) } keys %Queues ) { | |
129 | + $Self->{LayoutObject}->Block( | |
130 | + Name => 'ChangeRow', | |
131 | + Data => { | |
132 | + Type => "Queue", | |
133 | + ID => $queue, | |
134 | + Name => $Queues{$queue}, | |
135 | + Selected => ( $QueuesService{$queue} ? 'checked="checked"' : '' ) | |
136 | + } | |
137 | + ); | |
138 | + } | |
139 | + | |
140 | + my $Output = | |
141 | + $Self->{LayoutObject}->Header( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Services per queue") ); | |
142 | + $Output .= $Self->{LayoutObject}->NavigationBar(); | |
143 | + $Output .= $Self->{LayoutObject}->Output( | |
144 | + Data => \%Data, | |
145 | + TemplateFile => 'QueueServiceChange' | |
146 | + ); | |
147 | + | |
148 | + $Output .= $Self->{LayoutObject}->Footer(); | |
149 | + return $Output; | |
150 | +} | |
151 | + | |
152 | +sub ShowChangeQueue() { | |
153 | + my ( $Self, %Param ) = @_; | |
154 | + my %Data = (); | |
155 | + my %Queue = $Self->{QueueObject}->QueueGet( ID => $Param{ID} ); | |
156 | + my %ServicesQueue = $Self->{QueueServiceObject}->GetServiceList( QueueID => $Param{ID} ); | |
157 | + my %Services = $Self->{ServiceObject}->ServiceList( UserID => 1 ); | |
158 | + | |
159 | + $Data{Type} = "Service"; | |
160 | + $Data{Filter} = "Queue"; | |
161 | + $Data{VisibleNeType} = "Queue"; | |
162 | + $Data{Name} = $Queue{Name}; | |
163 | + $Data{ID} = $Queue{QueueID}; | |
164 | + | |
165 | + $Self->{LayoutObject}->Block( | |
166 | + Name => 'ChangeHeader', | |
167 | + Data => \%Data | |
168 | + ); | |
169 | + | |
170 | + foreach my $service ( sort { uc( $Services{$a} ) cmp uc( $Services{$b} ) } keys %Services ) { | |
171 | + $Self->{LayoutObject}->Block( | |
172 | + Name => 'ChangeRow', | |
173 | + Data => { | |
174 | + Type => "Service", | |
175 | + ID => $service, | |
176 | + Name => $Services{$service}, | |
177 | + Selected => ( $ServicesQueue{$service} ? 'checked="checked"' : '' ) | |
178 | + } | |
179 | + ); | |
180 | + } | |
181 | + | |
182 | + my $Output = | |
183 | + $Self->{LayoutObject}->Header( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Services per queue") ); | |
184 | + $Output .= $Self->{LayoutObject}->NavigationBar(); | |
185 | + $Output .= $Self->{LayoutObject}->Output( | |
186 | + Data => \%Data, | |
187 | + TemplateFile => 'QueueServiceChange' | |
188 | + ); | |
189 | + | |
190 | + $Output .= $Self->{LayoutObject}->Footer(); | |
191 | + return $Output; | |
192 | + | |
193 | +} | |
194 | + | |
195 | +sub ChangeService() { | |
196 | + my ( $Self, %Param ) = @_; | |
197 | + my @queueIDs = $Self->{ParamObject}->GetArray( Param => 'Queue' ); | |
198 | + my $id = $Self->{ParamObject}->GetParam( Param => 'ID' ); | |
199 | + $Self->{QueueServiceObject}->SetServiceQueues(ServiceID => $id, Queues => \@queueIDs); | |
200 | +} | |
201 | + | |
202 | + | |
203 | +sub ChangeQueue() { | |
204 | + my ( $Self, %Param ) = @_; | |
205 | + my @serviceIDs = $Self->{ParamObject}->GetArray( Param => 'Service' ); | |
206 | + my $id = $Self->{ParamObject}->GetParam( Param => 'ID' ); | |
207 | + $Self->{QueueServiceObject}->SetQueueServices(QueueID => $id, Services => \@serviceIDs); | |
208 | + | |
209 | +} | |
0 | 210 | \ No newline at end of file | ... | ... |
1 | +++ a/Kernel/Output/HTML/Standard/QueueService.dtl | |
... | ... | @@ -0,0 +1,87 @@ |
1 | +# -- | |
2 | +# Kernel/Output/HTML/Standard/QueueService.dtl - overview | |
3 | +# Copyright (C) (2014) (Rodrigo Gonçalves) (rodrigo.g@ufsc.br) | |
4 | +# -- | |
5 | +# $Id: writing-otrs-application.xml,v 1.1 2010/08/13 08:59:28 mg Exp $ | |
6 | +# -- | |
7 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
8 | +# the enclosed file COPYING for license information (AGPL). If you | |
9 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
10 | +# -- | |
11 | +<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst"> | |
12 | + <h1>$Text{"Services per queue"}</h1> | |
13 | + | |
14 | + <div class="SidebarColumn"> | |
15 | + | |
16 | + <div class="WidgetSimple"> | |
17 | + <div class="Header"> | |
18 | + <h2>$Text{"Actions"}</h2> | |
19 | + </div> | |
20 | + <div class="Content"> | |
21 | + <ul class="ActionList"> | |
22 | + <li> | |
23 | + <a href="$Env{"Baselink"}Action=$Env{"Action"}" class="CallForAction"><span>$Text{"Go to overview"}</span></a> | |
24 | + </li> | |
25 | + </ul> | |
26 | + </div> | |
27 | + </div> | |
28 | + | |
29 | +<!-- dtl:block:serviceFilter --> | |
30 | + <div class="WidgetSimple"> | |
31 | + <div class="Header"> | |
32 | + <h2><label for="FilterServices">$Text{"Services"}</label></h2> | |
33 | + </div> | |
34 | + <div class="Content"> | |
35 | + <input type="text" id="FilterUsers" class="W50pc" name="FilterUser" value="" title="$Text{"Service"}" /> | |
36 | + </div> | |
37 | + </div> | |
38 | +<!-- dtl:block:serviceFilter --> | |
39 | +<!-- dtl:block:queueFilter --> | |
40 | + <div class="WidgetSimple"> | |
41 | + <div class="Header"> | |
42 | + <h2><label for="FilterQueues">$Text{"Queues"}</label></h2> | |
43 | + </div> | |
44 | + <div class="Content"> | |
45 | + <input type="text" id="FilterGroups" class="W50pc" name="FilterGroups" value="" title="$Text{"Queue"}"/> | |
46 | + </div> | |
47 | + </div> | |
48 | +<!-- dtl:block:queueFilter --> | |
49 | + </div> | |
50 | + | |
51 | + <div class="ContentColumn"> | |
52 | + <div class="WidgetSimple"> | |
53 | + | |
54 | + <div class="Header"> | |
55 | + <h2>$Text{"Overview"}</h2> | |
56 | + </div> | |
57 | + <div class="Content LayoutGrid ColumnsWithSpacing"> | |
58 | + <div class="Size1of2"> | |
59 | + <ul class="Tablelike" id="Services"> | |
60 | + <li class="Header">$Text{"Services"}</li> | |
61 | + <li class="FilterMessage Hidden">$Text{"No matches found."}</li> | |
62 | +<!-- dtl:block:ListService--> | |
63 | + <li><a href="$Env{"Baselink"}Action=$Env{"Action"};Subaction=ServiceEdit;ID=$LQData{"ServiceID"}" class="AsBlock">$QData{"ServiceName"}</a></li> | |
64 | +<!-- dtl:block:ListService--> | |
65 | + </ul> | |
66 | + </div> | |
67 | + <div class="Size1of2"> | |
68 | + <ul class="Tablelike" id="Queues"> | |
69 | + <li class="Header">$Text{"Queues"}</li> | |
70 | + <li class="FilterMessage Hidden">$Text{"No matches found."}</li> | |
71 | +<!-- dtl:block:ListQueue--> | |
72 | + <li><a href="$Env{"Baselink"}Action=$Env{"Action"};Subaction=QueueEdit;ID=$LQData{"QueueID"}" class="AsBlock">$QData{"QueueName"}</a></li> | |
73 | +<!-- dtl:block:ListQueue--> | |
74 | + </ul> | |
75 | + </div> | |
76 | + <div class="Clear"></div> | |
77 | + </div> | |
78 | + | |
79 | + | |
80 | +<!-- dtl:js_on_document_complete --> | |
81 | +<script type="text/javascript">//<![CDATA[ | |
82 | + Core.UI.Table.InitTableFilter($('#FilterServices'), $('#Services')); | |
83 | + Core.UI.Table.InitTableFilter($('#FilterQueues'), $('#Queues')); | |
84 | +//]]></script> | |
85 | +<!-- dtl:js_on_document_complete --> | |
86 | + | |
87 | + | |
0 | 88 | \ No newline at end of file | ... | ... |
1 | +++ a/Kernel/Output/HTML/Standard/QueueServiceChange.dtl | |
... | ... | @@ -0,0 +1,95 @@ |
1 | +<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst"> | |
2 | + <h1>$Text{"Services and queues"}</h1> | |
3 | + <div class="SidebarColumn"> | |
4 | + <div class="WidgetSimple"> | |
5 | + <div class="Header"> | |
6 | + <h2>$Text{"Actions"}</h2> | |
7 | + </div> | |
8 | + <div class="Content"> | |
9 | + <ul class="ActionList"> | |
10 | + <li> | |
11 | + <a href="$Env{"Baselink"}Action=$Env{"Action"}" class="CallForAction"><span>$Text{"Go to overview"}</span></a> | |
12 | + </li> | |
13 | + </ul> | |
14 | + </div> | |
15 | + </div> | |
16 | + <div class="WidgetSimple"> | |
17 | + <div class="Header"> | |
18 | + <h2> | |
19 | + <label for="Filter">$Text{"Filter"}</label> | |
20 | + </h2> | |
21 | + </div> | |
22 | + <div class="Content"> | |
23 | + <input type="text" id="Filter" class="W50pc" name="Filter" value="" title="$Text{"Filter"}" /> | |
24 | + </div> | |
25 | + </div> | |
26 | + </div> | |
27 | + | |
28 | + <div class="ContentColumn"> | |
29 | + <div class="WidgetSimple"> | |
30 | + <div class="Header"> | |
31 | + <h2> | |
32 | +<!-- dtl:block:ChangeHeaderService --> | |
33 | + $Text{"Select queues for the service"} | |
34 | +<!-- dtl:block:ChangeHeaderService --> | |
35 | +<!-- dtl:block:ChangeHeaderQueue --> | |
36 | + $Text{"Select services for the queue"} | |
37 | +<!-- dtl:block:ChangeHeaderQueue --> | |
38 | + $QData{"Name"} | |
39 | + </h2> | |
40 | + </div> | |
41 | + <div class="Content "> | |
42 | + <form action="$Env{"CGIHandle"}" method="post" name="matrix"> | |
43 | + <input type="hidden" name="Action" value="$Env{"Action"}"/> | |
44 | + <input type="hidden" name="Subaction" value="Change$QData{"VisibleNeType"}"/> | |
45 | + <input type="hidden" name="ID" value="$QData{"ID"}"/> | |
46 | + <table class="DataTable VariableWidth" id="ServicesQueues"> | |
47 | + <thead> | |
48 | + <tr> | |
49 | + <th>$Text{"$Data{"VisibleNeType"}"}</th> | |
50 | +<!-- dtl:block:ChangeHeader --> | |
51 | + <th class="Center $QData{"Mark"}"> | |
52 | + <input type="checkbox" name="$QData{"Type"}" id="SelectAll$QData{"Type"}" title="$Text{"Toggle active state for all"}" value="" /> | |
53 | + $Text{"Active"} | |
54 | + </th> | |
55 | +<!-- dtl:js_on_document_complete --> | |
56 | +<script type="text/javascript">//<![CDATA[ | |
57 | + Core.Form.InitSelectAllCheckboxes($('table td input:checkbox[name=$QData{"Type"}]'), $('#SelectAll$QData{"Type"}')); | |
58 | + $('input:checkbox[name=$QData{"Type"}]').bind('click', function () { | |
59 | + Core.Form.SelectAllCheckboxes($(this), $('#SelectAll$QData{"Type"}')); | |
60 | + }); | |
61 | +//]]></script> | |
62 | +<!-- dtl:js_on_document_complete --> | |
63 | +<!-- dtl:block:ChangeHeader --> | |
64 | + </tr> | |
65 | + </thead> | |
66 | + <tbody> | |
67 | +<!-- dtl:block:ChangeRow --> | |
68 | + <tr> | |
69 | + <td>$QData{"Name"}</td> | |
70 | + <td class="$QData{"Mark"}"> | |
71 | + <input type="checkbox" name="$QData{"Type"}" title="$Text{"Toggle active state for %s", "$QData{"Name"}"}" value="$QData{"ID"}" $Data{"Selected"}/> | |
72 | + </td> | |
73 | + </tr> | |
74 | +<!-- dtl:block:ChangeRow --> | |
75 | + </tbody> | |
76 | + </table> | |
77 | + <div class="Field SpacingTop"> | |
78 | + <button class="Primary" type="submit" value="$Text{"Submit"}">$Text{"Submit"}</button> | |
79 | + $Text{"or"} | |
80 | + <a href="$Env{"Baselink"}Action=$Env{"Action"}">$Text{"Cancel"}</a> | |
81 | + </div> | |
82 | + <div class="Clear"></div> | |
83 | + </form> | |
84 | + </div> | |
85 | + </div> | |
86 | + </div> | |
87 | + <div class="Clear"></div> | |
88 | +</div> | |
89 | + | |
90 | +<!-- dtl:js_on_document_complete --> | |
91 | +<script type="text/javascript">//<![CDATA[ | |
92 | + Core.UI.Table.InitTableFilter($('#Filter'), $('#ServicesQueues')); | |
93 | + Core.Form.HideSelectAllCheckboxes($('#ServicesQueues'), '#SelectAll$QData{"Type"}'); | |
94 | +//]]></script> | |
95 | +<!-- dtl:js_on_document_complete --> | ... | ... |
1 | +++ a/Kernel/System/QueueService.pm | |
... | ... | @@ -0,0 +1,187 @@ |
1 | +# -- | |
2 | +# Kernel/System/QueueService.pm - core module | |
3 | +# Managers Queue Services | |
4 | +# | |
5 | +# Copyright (C) (2014) (Carlos Rebelato, Rodrigo Gonçalves) (rodrigo.g@ufsc.br) | |
6 | +# -- | |
7 | +# $Id: writing-otrs-application.xml,v 1.1 2010/08/13 08:59:28 mg Exp $ | |
8 | +# -- | |
9 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
10 | +# the enclosed file COPYING for license information (AGPL). If you | |
11 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
12 | +# -- | |
13 | +# Author: Carlos Rebelato | |
14 | +# Date..: 19/02/2014 - Versão inicial | |
15 | +# Revision: 27/02/2014 - Module creation | |
16 | +# | |
17 | +package Kernel::System::QueueService; | |
18 | + | |
19 | +use strict; | |
20 | +use warnings; | |
21 | +use Data::Dumper; | |
22 | + | |
23 | +sub new { | |
24 | + my ( $Type, %Param ) = @_; | |
25 | + | |
26 | + # allocate new hash for object | |
27 | + my $Self = {%Param}; | |
28 | + bless( $Self, $Type ); | |
29 | + | |
30 | + return $Self; | |
31 | +} | |
32 | + | |
33 | +=item GetServiceList() | |
34 | + | |
35 | +Get list of services for a queue | |
36 | + | |
37 | + my %{service_id}{QueueName} = $QueueServiceObject->GetServiceList( | |
38 | + QueueID => 123, | |
39 | + ); | |
40 | + | |
41 | +=cut | |
42 | +sub GetServiceList { | |
43 | + my ( $Self, %Param ) = @_; | |
44 | + my %result = (); | |
45 | + | |
46 | + for (qw(QueueID)) { | |
47 | + if ( !$Param{$_} ) { | |
48 | + $Self->{LayoutObject}->FatalError( Message => Dumper( \%Param ) . "got no $_!" ); | |
49 | + } | |
50 | + } | |
51 | + | |
52 | + $Self->{DBObject}->Prepare( | |
53 | + SQL => " | |
54 | + select | |
55 | + a.service_id id, | |
56 | + b.name Name | |
57 | + from | |
58 | + queue_service a | |
59 | + inner join service b on(b.id = a.service_id) | |
60 | + where | |
61 | + a.queue_id = ?", | |
62 | + Bind => [ \$Param{QueueID} ] | |
63 | + ); | |
64 | + | |
65 | + while ( my @row = $Self->{DBObject}->FetchrowArray() ) { | |
66 | + $result{ $row[0] } = $row[1]; | |
67 | + } | |
68 | + | |
69 | + return %result; | |
70 | +} | |
71 | + | |
72 | +=item GetQueueList() | |
73 | + | |
74 | +Get list of queues for a service | |
75 | + | |
76 | + my %{queue_id}{QueueName} = $QueueServiceObject->GetQueueList( | |
77 | + ServiceID => 123, | |
78 | + ); | |
79 | + | |
80 | +=cut | |
81 | +sub GetQueueList { | |
82 | + my ( $Self, %Param ) = @_; | |
83 | + my %result = (); | |
84 | + | |
85 | + for (qw(ServiceID)) { | |
86 | + if ( !$Param{$_} ) { | |
87 | + $Self->{LayoutObject}->FatalError( Message => Dumper( \%Param ) . "got no $_!" ); | |
88 | + } | |
89 | + } | |
90 | + | |
91 | + $Self->{DBObject}->Prepare( | |
92 | + SQL => " | |
93 | + select | |
94 | + a.queue_id id, | |
95 | + b.name Name | |
96 | + from | |
97 | + queue_service a | |
98 | + inner join queue b on(b.id = a.queue_id) | |
99 | + where | |
100 | + a.service_id = ?", | |
101 | + Bind => [ \$Param{ServiceID} ] | |
102 | + ); | |
103 | + | |
104 | + while ( my @row = $Self->{DBObject}->FetchrowArray() ) { | |
105 | + $result{ $row[0] } = $row[1]; | |
106 | + } | |
107 | + | |
108 | + return %result; | |
109 | +} | |
110 | + | |
111 | + | |
112 | +=item SetQueueServices() | |
113 | + | |
114 | +Defines the list of services for a queue | |
115 | + | |
116 | + $QueueServiceObject->SetQueueServices( | |
117 | + QueueID => 123, | |
118 | + Services => @ServiceIDs | |
119 | + ); | |
120 | + | |
121 | +=cut | |
122 | +sub SetQueueServices { | |
123 | + my ( $Self, %Param ) = @_; | |
124 | + my %result = (); | |
125 | + | |
126 | + for (qw(QueueID Services)) { | |
127 | + if ( !$Param{$_} ) { | |
128 | + $Self->{LayoutObject}->FatalError( Message => Dumper( \%Param ) . "got no $_!" ); | |
129 | + } | |
130 | + } | |
131 | + | |
132 | + my $QueueID = $Param{"QueueID"}; | |
133 | + my @Services = @{$Param{"Services"}}; | |
134 | + | |
135 | + $Self->{DBObject}->Do( | |
136 | + SQL => "delete from queue_service where queue_id = ?", | |
137 | + Bind => [ \$Param{QueueID} ] | |
138 | + ); | |
139 | + | |
140 | + for my $service (@Services) { | |
141 | + $Self->{DBObject}->Do( | |
142 | + SQL => "insert into queue_service(queue_id,service_id) values (?,?)", | |
143 | + Bind => [\$Param{QueueID}, \$service] | |
144 | + ); | |
145 | + | |
146 | + } | |
147 | +} | |
148 | + | |
149 | +=item SetServiceQueues() | |
150 | + | |
151 | +Defines the list of services for a queue | |
152 | + | |
153 | + $QueueServiceObject->SetServiceQueues( | |
154 | + ServiceID => 123, | |
155 | + Queues => @ServiceIDs | |
156 | + ); | |
157 | + | |
158 | +=cut | |
159 | +sub SetServiceQueues { | |
160 | + my ( $Self, %Param ) = @_; | |
161 | + my %result = (); | |
162 | + | |
163 | + for (qw(ServiceID Queues)) { | |
164 | + if ( !$Param{$_} ) { | |
165 | + $Self->{LayoutObject}->FatalError( Message => Dumper( \%Param ) . "got no $_!" ); | |
166 | + } | |
167 | + } | |
168 | + | |
169 | + my $ServiceID = $Param{"ServiceID"}; | |
170 | + my @Queues = @{$Param{"Queues"}}; | |
171 | + | |
172 | + $Self->{DBObject}->Do( | |
173 | + SQL => "delete from queue_service where service_id = ?", | |
174 | + Bind => [ \$Param{ServiceID} ] | |
175 | + ); | |
176 | + | |
177 | + for my $queue (@Queues) { | |
178 | + $Self->{DBObject}->Do( | |
179 | + SQL => "insert into queue_service(queue_id,service_id) values (?,?)", | |
180 | + Bind => [\$queue, \$Param{ServiceID}] | |
181 | + ); | |
182 | + | |
183 | + } | |
184 | +} | |
185 | + | |
186 | + | |
187 | +1; | ... | ... |
1 | +++ a/QueueService.sopm | |
... | ... | @@ -0,0 +1,40 @@ |
1 | +<?xml version="1.0" encoding="utf-8" ?> | |
2 | +<otrs_package version="1.0"> | |
3 | + <Name>QueueService</Name> | |
4 | + <Version>1.0.0</Version> | |
5 | + <Framework>3.x.x</Framework> | |
6 | + <Vendor>SeTIC</Vendor> | |
7 | + <URL>http://www.setic.ufsc.br</URL> | |
8 | + <License>Free</License> | |
9 | + <Description Lang="pt-br">Associação de serviços a filas | |
10 | + | |
11 | + Versão 1.0.0 - Inicial | |
12 | + | |
13 | + </Description> | |
14 | + <IntroInstall Type="post" Lang="pt-br" Title="Obrigado">Módulo instalado com sucesso!</IntroInstall> | |
15 | + <Description Lang="en">New Ticket Wizard</Description> | |
16 | + <IntroInstall Type="post" Lang="en" Title="Thank you">Queue services module installed successfully!</IntroInstall> | |
17 | + <BuildDate>?</BuildDate> | |
18 | + <BuildHost>?</BuildHost> | |
19 | + <Filelist> | |
20 | + <File Permission="644" Location="Kernel/Config/Files/QueueService.xml"></File> | |
21 | + <File Permission="644" Location="Kernel/Language/pt_BR_QueueService.pm"></File> | |
22 | + <File Permission="644" Location="Kernel/Modules/QueueService.pm"></File> | |
23 | + <File Permission="644" Location="Kernel/Output/HTML/Standard/QueueService.dtl"></File> | |
24 | + <File Permission="644" Location="Kernel/Output/HTML/Standard/QueueServiceChange.dtl"></File> | |
25 | + <File Permission="644" Location="Kernel/System/QueueService.pm"></File> | |
26 | + </Filelist> | |
27 | + <DatabaseInstall> | |
28 | + <TableCreate Name="queue_service"> | |
29 | + <Column Name="id" Required="true" PrimaryKey="true" AutoIncrement="true" Type="int"/> | |
30 | + <Column Name="service_id" Required="true" Type="int"/> | |
31 | + <Column Name="queue_id" Required="true" Type="int"/> | |
32 | + <ForeignKey ForeignTable="service"> | |
33 | + <Reference Local="service_id" Foreign="id"/> | |
34 | + </ForeignKey> | |
35 | + <ForeignKey ForeignTable="queue"> | |
36 | + <Reference Local="queue_id" Foreign="id"/> | |
37 | + </ForeignKey> | |
38 | + </TableCreate> | |
39 | + </DatabaseInstall> | |
40 | +</otrs_package> | |
0 | 41 | \ No newline at end of file | ... | ... |