Commit 0020e11e3128f96926d85d5981cbbb8e76e5167a

Authored by Rodrigo Goncalves
1 parent 5a91ab5c
Exists in master

Suporte para OTRS 6

.gitignore 0 → 100644
... ... @@ -0,0 +1 @@
  1 +dist/*
... ...
CreateOpm.sh
1 1 #!/bin/bash
2 2 LOCAL="$PWD"
3 3 cd /opt/otrs
4   -bin/otrs.Console.pl Dev::Package::Build "$LOCAL"/QueueService.sopm "$LOCAL"/
  4 +bin/otrs.Console.pl Dev::Package::Build "$LOCAL"/src/QueueService.sopm "$LOCAL"/dist/
5 5 cd $LOCAL
... ...
Kernel/Config/Files/QueueService.xml
... ... @@ -1,27 +0,0 @@
1   -<?xml version="1.0" encoding="UTF-8" ?>
2   -<otrs_config init="Application" version="1.0">
3   - <ConfigItem Name="Frontend::Module###QueueService" Required="0" Valid="1">
4   - <Description Lang="en">Frontend module registration for the service per queue</Description>
5   - <Description Lang="pt_BR">Registro do módulo de serviços por fila</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 Lang="en">Services per queue</Title>
13   - <Title Lang="pt_BR">Serviços por fila</Title>
14   - <NavBarName>Admin</NavBarName>
15   - <NavBarModule>
16   - <Module>Kernel::Output::HTML::NavBar::ModuleAdmin</Module>
17   - <Name Lang="en">Services per queue</Name>
18   - <Name Lang="pt_BR">Serviços por fila</Name>
19   - <Description Lang="en">Create and manages services per queue</Description>
20   - <Description Lang="pt_BR">Cria e gerencia serviços por fila</Description>
21   - <Block>Ticket</Block>
22   - <Prio>900</Prio>
23   - </NavBarModule>
24   - </FrontendModuleReg>
25   - </Setting>
26   - </ConfigItem>
27   -</otrs_config>
Kernel/Language/pt_BR_QueueService.pm
... ... @@ -1,26 +0,0 @@
1   -# --
2   -# Kernel/Modules/pt_BR_QueueService.pm - module to associate services per queue
3   -#
4   -# Copyright (C) 2014 - SeTIC - UFSC - http://setic.ufsc.br/
5   -# Version 01/06/2015 - Adjusts for OTRS 4
6   -#
7   -# --
8   -# This software comes with ABSOLUTELY NO WARRANTY. For details, see
9   -# the enclosed file COPYING for license information (AGPL). If you
10   -# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
11   -# --
12   -package Kernel::Language::pt_BR_QueueService;
13   -
14   -use strict;
15   -use warnings;
16   -use utf8;
17   -
18   -sub Data {
19   - my $Self = shift;
20   - $Self->{Translation}->{'Services per queue'} = 'Serviços por fila';
21   - $Self->{Translation}->{'Create and manages services per queue'} = 'Cria e gerencia serviços por fila';
22   -
23   - return 1;
24   -}
25   -
26   -1;
27 0 \ No newline at end of file
Kernel/Modules/QueueService.pm
... ... @@ -1,208 +0,0 @@
1   -# --
2   -# Kernel/Modules/QueueService.pm - frontend module
3   -#
4   -# Copyright (C) 2014 - SeTIC - UFSC - http://setic.ufsc.br/
5   -# Version 01/06/2015 - Adjusts for OTRS 4
6   -#
7   -# Autor: Carlos Rebelato, Rodrigo Gonçalves
8   -# Data.: 19/02/2014 - Versão inicial
9   -#
10   -package Kernel::Modules::QueueService;
11   -
12   -use strict;
13   -use warnings;
14   -use Data::Dumper;
15   -require Kernel::System::QueueService;
16   -require Kernel::System::Service;
17   -require Kernel::System::Queue;
18   -
19   -our @ObjectDependencies = (
20   - "Kernel::System::Web::Request", # Old ParamObject
21   - "Kernel::System::DB",
22   - "Kernel::System::Ticket",
23   - "Kernel::Output::HTML::Layout", # Old LayoutObject
24   - "Kernel::System::Log",
25   - "Kernel::System::Queue",
26   - "Kernel::Config",
27   - "Kernel::System::Encode",
28   - "Kernel::System::Main",
29   - "Kernel::System::QueueService", # Ask direct to manager
30   - "Kernel::System::Service" # Ask direct to manager
31   -);
32   -
33   -sub new {
34   - my ( $Type, %Param ) = @_;
35   -
36   - # allocate new hash for object
37   - my $Self = {%Param};
38   - bless( $Self, $Type );
39   -
40   - return $Self;
41   -}
42   -
43   -sub Run {
44   - my ( $Self, %Param ) = @_;
45   -
46   - my $ParamObject = $Kernel::OM->Get("Kernel::System::Web::Request");
47   -
48   - my $SubAction = $ParamObject->GetParam( Param => "Subaction" );
49   -
50   - if ( $SubAction eq "ServiceEdit" ) {
51   - return $Self->ShowChangeService( ID => $ParamObject->GetParam( Param => "ID" ) );
52   - }
53   - elsif ( $SubAction eq "QueueEdit" ) {
54   - return $Self->ShowChangeQueue( ID => $ParamObject->GetParam( Param => "ID" ) );
55   - }
56   - elsif ( $SubAction eq "ChangeService" ) {
57   - $Self->ChangeService();
58   - return $Self->ShowOverview();
59   - }
60   - elsif ( $SubAction eq "ChangeQueue" ) {
61   - $Self->ChangeQueue();
62   - return $Self->ShowOverview();
63   - }
64   - else {
65   - return $Self->ShowOverview();
66   - }
67   -}
68   -
69   -sub ShowOverview() {
70   - my ( $Self, %Param ) = @_;
71   - my %Data = ();
72   -
73   - my %Queues = $Kernel::OM->Get("Kernel::System::Queue")->QueueList( Valid => 1 );
74   - my %Services = $Kernel::OM->Get("Kernel::System::Service")->ServiceList( UserID => 1 );
75   - my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
76   -
77   - foreach my $service ( sort { uc( $Services{$a} ) cmp uc( $Services{$b} ) } keys %Services ) {
78   - $LayoutObject->Block(
79   - Name => 'ListService',
80   - Data => {
81   - ServiceID => $service,
82   - ServiceName => $Services{$service},
83   - }
84   - );
85   - }
86   -
87   - foreach my $queue ( sort { uc( $Queues{$a} ) cmp uc( $Queues{$b} ) } keys %Queues ) {
88   - $LayoutObject->Block(
89   - Name => 'ListQueue',
90   - Data => {
91   - QueueID => $queue,
92   - QueueName => $Queues{$queue},
93   - }
94   - );
95   - }
96   -
97   - my $Output = $LayoutObject->Header( Title => $LayoutObject->{LanguageObject}->Get("Services per queue") );
98   - $Output .= $LayoutObject->NavigationBar();
99   - $Output .= $LayoutObject->Output(
100   - Data => \%Data,
101   - TemplateFile => 'QueueService'
102   - );
103   -
104   - $Output .= $LayoutObject->Footer();
105   - return $Output;
106   -}
107   -
108   -sub ShowChangeService() {
109   - my ( $Self, %Param ) = @_;
110   - my %Data = ();
111   - my %Service = $Kernel::OM->Get("Kernel::System::Service")->ServiceGet( ServiceID => $Param{ID}, UserID => 1 );
112   - my %QueuesService = $Kernel::OM->Get("Kernel::System::QueueService")->GetQueueList( ServiceID => $Param{ID} );
113   - my %Queues = $Kernel::OM->Get("Kernel::System::Queue")->QueueList( Valid => 1 );
114   - my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
115   -
116   - $Data{Type} = "Queue";
117   - $Data{Filter} = "Service";
118   - $Data{VisibleNeType} = "Service";
119   - $Data{Name} = $Service{Name};
120   - $Data{ID} = $Service{ServiceID};
121   -
122   - $LayoutObject->Block(
123   - Name => 'ChangeHeader',
124   - Data => \%Data
125   - );
126   -
127   - foreach my $queue ( sort { uc( $Queues{$a} ) cmp uc( $Queues{$b} ) } keys %Queues ) {
128   - $LayoutObject->Block(
129   - Name => 'ChangeRow',
130   - Data => {
131   - Type => "Queue",
132   - ID => $queue,
133   - Name => $Queues{$queue},
134   - Selected => ( $QueuesService{$queue} ? 'checked="checked"' : '' )
135   - }
136   - );
137   - }
138   -
139   - my $Output =
140   - $LayoutObject->Header( Title => $LayoutObject->{LanguageObject}->Get("Services per queue") );
141   - $Output .= $LayoutObject->NavigationBar();
142   - $Output .= $LayoutObject->Output(
143   - Data => \%Data,
144   - TemplateFile => 'QueueServiceChange'
145   - );
146   -
147   - $Output .= $LayoutObject->Footer();
148   - return $Output;
149   -}
150   -
151   -sub ShowChangeQueue() {
152   - my ( $Self, %Param ) = @_;
153   - my %Data = ();
154   - my %Queue = $Kernel::OM->Get("Kernel::System::Queue")->QueueGet( ID => $Param{ID} );
155   - my %ServicesQueue = $Kernel::OM->Get("Kernel::System::QueueService")->GetServiceList( QueueID => $Param{ID} );
156   - my %Services = $Kernel::OM->Get("Kernel::System::Service")->ServiceList( UserID => 1 );
157   - my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
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   - $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   - $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   - $LayoutObject->Header( Title => $LayoutObject->{LanguageObject}->Get("Services per queue") );
184   - $Output .= $LayoutObject->NavigationBar();
185   - $Output .= $LayoutObject->Output(
186   - Data => \%Data,
187   - TemplateFile => 'QueueServiceChange'
188   - );
189   -
190   - $Output .= $LayoutObject->Footer();
191   - return $Output;
192   -
193   -}
194   -
195   -sub ChangeService() {
196   - my ( $Self, %Param ) = @_;
197   - my @queueIDs = $Kernel::OM->Get("Kernel::System::Web::Request")->GetArray( Param => 'Queue' );
198   - my $id = $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => 'ID' );
199   - $Kernel::OM->Get("Kernel::System::QueueService")->SetServiceQueues(ServiceID => $id, Queues => \@queueIDs);
200   -}
201   -
202   -sub ChangeQueue() {
203   - my ( $Self, %Param ) = @_;
204   - my @serviceIDs = $Kernel::OM->Get("Kernel::System::Web::Request")->GetArray( Param => 'Service' );
205   - my $id = $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => 'ID' );
206   - $Kernel::OM->Get("Kernel::System::QueueService")->SetQueueServices(QueueID => $id, Services => \@serviceIDs);
207   -
208   -}
209 0 \ No newline at end of file
Kernel/Output/HTML/Templates/Standard/QueueService.tt
... ... @@ -1,86 +0,0 @@
1   -# --
2   -# Kernel/Output/HTML/Standard/QueueService.tt - overview
3   -# Copyright (C) (2014) SeTIC - UFSC - http://setic.ufsc.br/
4   -# Version 06/01/2015 - Adjusts for OTRS 4
5   -#
6   -# This software comes with ABSOLUTELY NO WARRANTY. For details, see
7   -# the enclosed file COPYING for license information (AGPL). If you
8   -# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
9   -# --
10   -<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst">
11   - <h1>[% Translate("Services per queue") | html %]</h1>
12   -
13   - <div class="SidebarColumn">
14   -
15   - <div class="WidgetSimple">
16   - <div class="Header">
17   - <h2>[% Translate("Actions") | html %]</h2>
18   - </div>
19   - <div class="Content">
20   - <ul class="ActionList">
21   - <li>
22   - <a href="[% Env("Baselink") %]Action=[% Env("Action") %]" class="CallForAction"><span>[% Translate("Go to overview") | html %]</span></a>
23   - </li>
24   - </ul>
25   - </div>
26   - </div>
27   -
28   -[% RenderBlockStart("serviceFilter") %]
29   - <div class="WidgetSimple">
30   - <div class="Header">
31   - <h2><label for="FilterServices">[% Translate("Services") | html %]</label></h2>
32   - </div>
33   - <div class="Content">
34   - <input type="text" id="FilterUsers" class="W50pc" name="FilterUser" value="" title="[% Translate("Service") | html %]" />
35   - </div>
36   - </div>
37   -[% RenderBlockEnd("serviceFilter") %]
38   -[% RenderBlockStart("queueFilter") %]
39   - <div class="WidgetSimple">
40   - <div class="Header">
41   - <h2><label for="FilterQueues">[% Translate("Queues") | html %]</label></h2>
42   - </div>
43   - <div class="Content">
44   - <input type="text" id="FilterGroups" class="W50pc" name="FilterGroups" value="" title="[% Translate("Queue") | html %]"/>
45   - </div>
46   - </div>
47   -[% RenderBlockEnd("queueFilter") %]
48   - </div>
49   -
50   - <div class="ContentColumn">
51   - <div class="WidgetSimple">
52   -
53   - <div class="Header">
54   - <h2>[% Translate("Overview") | html %]</h2>
55   - </div>
56   - <div class="Content LayoutGrid ColumnsWithSpacing">
57   - <div class="Size1of2">
58   - <ul class="Tablelike" id="Services">
59   - <li class="Header">[% Translate("Services") | html %]</li>
60   - <li class="FilterMessage Hidden">[% Translate("No matches found.") | html %]</li>
61   -[% RenderBlockStart("ListService") %]
62   - <li><a href="[% Env("Baselink") %]Action=[% Env("Action") %];Subaction=ServiceEdit;ID=[% Data.ServiceID | uri %]" class="AsBlock">[% Data.ServiceName | html %]</a></li>
63   -[% RenderBlockEnd("ListService") %]
64   - </ul>
65   - </div>
66   - <div class="Size1of2">
67   - <ul class="Tablelike" id="Queues">
68   - <li class="Header">[% Translate("Queues") | html %]</li>
69   - <li class="FilterMessage Hidden">[% Translate("No matches found.") | html %]</li>
70   -[% RenderBlockStart("ListQueue") %]
71   - <li><a href="[% Env("Baselink") %]Action=[% Env("Action") %];Subaction=QueueEdit;ID=[% Data.QueueID | uri %]" class="AsBlock">[% Data.QueueName | html %]</a></li>
72   -[% RenderBlockEnd("ListQueue") %]
73   - </ul>
74   - </div>
75   - <div class="Clear"></div>
76   - </div>
77   -
78   -
79   -[% WRAPPER JSOnDocumentComplete %]
80   -<script type="text/javascript">//<![CDATA[
81   - Core.UI.Table.InitTableFilter($('#FilterServices'), $('#Services'));
82   - Core.UI.Table.InitTableFilter($('#FilterQueues'), $('#Queues'));
83   -//]]></script>
84   -[% END %]
85   -
86   -
87 0 \ No newline at end of file
Kernel/Output/HTML/Templates/Standard/QueueServiceChange.tt
... ... @@ -1,103 +0,0 @@
1   -# --
2   -# Kernel/Output/HTML/Standard/QueueServiceChange.tt - edit
3   -# Copyright (C) (2014) SeTIC - UFSC - http://setic.ufsc.br/
4   -# Version 06/01/2015 - Adjusts for OTRS 4
5   -#
6   -# This software comes with ABSOLUTELY NO WARRANTY. For details, see
7   -# the enclosed file COPYING for license information (AGPL). If you
8   -# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
9   -# --
10   -<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst">
11   - <h1>[% Translate("Services and queues") | html %]</h1>
12   - <div class="SidebarColumn">
13   - <div class="WidgetSimple">
14   - <div class="Header">
15   - <h2>[% Translate("Actions") | html %]</h2>
16   - </div>
17   - <div class="Content">
18   - <ul class="ActionList">
19   - <li>
20   - <a href="[% Env("Baselink") %]Action=[% Env("Action") %]" class="CallForAction"><span>[% Translate("Go to overview") | html %]</span></a>
21   - </li>
22   - </ul>
23   - </div>
24   - </div>
25   - <div class="WidgetSimple">
26   - <div class="Header">
27   - <h2>
28   - <label for="Filter">[% Translate("Filter") | html %]</label>
29   - </h2>
30   - </div>
31   - <div class="Content">
32   - <input type="text" id="Filter" class="W50pc" name="Filter" value="" title="[% Translate("Filter") | html %]" />
33   - </div>
34   - </div>
35   - </div>
36   -
37   - <div class="ContentColumn">
38   - <div class="WidgetSimple">
39   - <div class="Header">
40   - <h2>
41   -[% RenderBlockStart("ChangeHeaderService") %]
42   - [% Translate("Select queues for the service") | html %]
43   -[% RenderBlockEnd("ChangeHeaderService") %]
44   -[% RenderBlockStart("ChangeHeaderQueue") %]
45   - [% Translate("Select services for the queue") | html %]
46   -[% RenderBlockEnd("ChangeHeaderQueue") %]
47   - [% Data.Name | html %]
48   - </h2>
49   - </div>
50   - <div class="Content ">
51   - <form action="[% Env("CGIHandle") %]" method="post" name="matrix">
52   - <input type="hidden" name="Action" value="[% Env("Action") %]"/>
53   - <input type="hidden" name="Subaction" value="Change[% Data.VisibleNeType | html %]"/>
54   - <input type="hidden" name="ID" value="[% Data.ID | html %]"/>
55   - <table class="DataTable VariableWidth" id="ServicesQueues">
56   - <thead>
57   - <tr>
58   - <th>[% Translate(Data.VisibleNeType) | html %]</th>
59   -[% RenderBlockStart("ChangeHeader") %]
60   - <th class="Center [% Data.Mark | html %]">
61   - <input type="checkbox" name="[% Data.Type | html %]" id="SelectAll[% Data.Type | html %]" title="[% Translate("Toggle active state for all") | html %]" value="" />
62   - [% Translate("Active") | html %]
63   - </th>
64   -[% WRAPPER JSOnDocumentComplete %]
65   -<script type="text/javascript">//<![CDATA[
66   - Core.Form.InitSelectAllCheckboxes($('table td input:checkbox[name=[% Data.Type | html %]]'), $('#SelectAll[% Data.Type | html %]'));
67   - $('input:checkbox[name=[% Data.Type | html %]]').bind('click', function () {
68   - Core.Form.SelectAllCheckboxes($(this), $('#SelectAll[% Data.Type | html %]'));
69   - });
70   -//]]></script>
71   -[% END %]
72   -[% RenderBlockEnd("ChangeHeader") %]
73   - </tr>
74   - </thead>
75   - <tbody>
76   -[% RenderBlockStart("ChangeRow") %]
77   - <tr>
78   - <td>[% Data.Name | html %]</td>
79   - <td class="[% Data.Mark | html %]">
80   - <input type="checkbox" name="[% Data.Type | html %]" title="[% Translate("Toggle active state for %s", Data.Name) | html %]" value="[% Data.ID | html %]" [% Data.Selected %]/>
81   - </td>
82   - </tr>
83   -[% RenderBlockEnd("ChangeRow") %]
84   - </tbody>
85   - </table>
86   - <div class="Field SpacingTop">
87   - <button class="Primary" type="submit" value="[% Translate("Submit") | html %]">[% Translate("Submit") | html %]</button>
88   - [% Translate("or") | html %]
89   - <a href="[% Env("Baselink") %]Action=[% Env("Action") %]">[% Translate("Cancel") | html %]</a>
90   - </div>
91   - <div class="Clear"></div>
92   - </form>
93   - </div>
94   - </div>
95   - </div>
96   - <div class="Clear"></div>
97   -</div>
98   -
99   -[% WRAPPER JSOnDocumentComplete %]
100   -<script type="text/javascript">//<![CDATA[
101   - Core.UI.Table.InitTableFilter($('#Filter'), $('#ServicesQueues'));
102   -//]]></script>
103   -[% END %]
Kernel/System/QueueService.pm
... ... @@ -1,188 +0,0 @@
1   -# --
2   -# Kernel/System/QueueService.pm - core module
3   -# Manages Queue Services
4   -#
5   -# Copyright (C) (2014) - SeTIC - UFSC - http://setic.ufsc.br/
6   -# Version 06/01/2015 - Adjusts for OTRS 4
7   -#
8   -# This software comes with ABSOLUTELY NO WARRANTY. For details, see
9   -# the enclosed file COPYING for license information (AGPL). If you
10   -# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
11   -# --
12   -#
13   -package Kernel::System::QueueService;
14   -
15   -use strict;
16   -use warnings;
17   -use Data::Dumper;
18   -
19   -our @ObjectDependencies = (
20   - "Kernel::Output::HTML::Layout", # Old LayoutObject
21   - "Kernel::System::DB"
22   -);
23   -
24   -sub new {
25   - my ( $Type, %Param ) = @_;
26   -
27   - # allocate new hash for object
28   - my $Self = {%Param};
29   - bless( $Self, $Type );
30   -
31   - return $Self;
32   -}
33   -
34   -=item GetServiceList()
35   -
36   -Get list of services for a queue
37   -
38   - my %{service_id}{QueueName} = $QueueServiceObject->GetServiceList(
39   - QueueID => 123,
40   - );
41   -
42   -=cut
43   -sub GetServiceList {
44   - my ( $Self, %Param ) = @_;
45   - my %result = ();
46   -
47   - for (qw(QueueID)) {
48   - if ( !$Param{$_} ) {
49   - $Kernel::OM->Get("Kernel::Output::HTML::Layout")->FatalError( Message => Dumper( \%Param ) . "got no $_!" );
50   - }
51   - }
52   -
53   - $Kernel::OM->Get("Kernel::System::DB")->Prepare(
54   - SQL => "
55   - select
56   - a.service_id id,
57   - b.name Name
58   - from
59   - queue_service a
60   - inner join service b on(b.id = a.service_id)
61   - where
62   - a.queue_id = ?",
63   - Bind => [ \$Param{QueueID} ]
64   - );
65   -
66   - while ( my @row = $Kernel::OM->Get("Kernel::System::DB")->FetchrowArray() ) {
67   - $result{ $row[0] } = $row[1];
68   - }
69   -
70   - return %result;
71   -}
72   -
73   -=item GetQueueList()
74   -
75   -Get list of queues for a service
76   -
77   - my %{queue_id}{QueueName} = $QueueServiceObject->GetQueueList(
78   - ServiceID => 123,
79   - );
80   -
81   -=cut
82   -sub GetQueueList {
83   - my ( $Self, %Param ) = @_;
84   - my %result = ();
85   -
86   - for (qw(ServiceID)) {
87   - if ( !$Param{$_} ) {
88   - $Kernel::OM->Get("Kernel::Output::HTML::Layout")->FatalError( Message => Dumper( \%Param ) . "got no $_!" );
89   - }
90   - }
91   -
92   - $Kernel::OM->Get("Kernel::System::DB")->Prepare(
93   - SQL => "
94   - select
95   - a.queue_id id,
96   - b.name Name
97   - from
98   - queue_service a
99   - inner join queue b on(b.id = a.queue_id)
100   - where
101   - a.service_id = ?",
102   - Bind => [ \$Param{ServiceID} ]
103   - );
104   -
105   - while ( my @row = $Kernel::OM->Get("Kernel::System::DB")->FetchrowArray() ) {
106   - $result{ $row[0] } = $row[1];
107   - }
108   -
109   - return %result;
110   -}
111   -
112   -
113   -=item SetQueueServices()
114   -
115   -Defines the list of services for a queue
116   -
117   - $QueueServiceObject->SetQueueServices(
118   - QueueID => 123,
119   - Services => @ServiceIDs
120   - );
121   -
122   -=cut
123   -sub SetQueueServices {
124   - my ( $Self, %Param ) = @_;
125   - my %result = ();
126   -
127   - for (qw(QueueID Services)) {
128   - if ( !$Param{$_} ) {
129   - $Kernel::OM->Get("Kernel::Output::HTML::Layout")->FatalError( Message => Dumper( \%Param ) . "got no $_!" );
130   - }
131   - }
132   -
133   - my $QueueID = $Param{"QueueID"};
134   - my @Services = @{$Param{"Services"}};
135   -
136   - $Kernel::OM->Get("Kernel::System::DB")->Do(
137   - SQL => "delete from queue_service where queue_id = ?",
138   - Bind => [ \$Param{QueueID} ]
139   - );
140   -
141   - for my $service (@Services) {
142   - $Kernel::OM->Get("Kernel::System::DB")->Do(
143   - SQL => "insert into queue_service(queue_id,service_id) values (?,?)",
144   - Bind => [\$Param{QueueID}, \$service]
145   - );
146   -
147   - }
148   -}
149   -
150   -=item SetServiceQueues()
151   -
152   -Defines the list of services for a queue
153   -
154   - $QueueServiceObject->SetServiceQueues(
155   - ServiceID => 123,
156   - Queues => @ServiceIDs
157   - );
158   -
159   -=cut
160   -sub SetServiceQueues {
161   - my ( $Self, %Param ) = @_;
162   - my %result = ();
163   -
164   - for (qw(ServiceID Queues)) {
165   - if ( !$Param{$_} ) {
166   - $Kernel::OM->Get("Kernel::Output::HTML::Layout")->FatalError( Message => Dumper( \%Param ) . "got no $_!" );
167   - }
168   - }
169   -
170   - my $ServiceID = $Param{"ServiceID"};
171   - my @Queues = @{$Param{"Queues"}};
172   -
173   - $Kernel::OM->Get("Kernel::System::DB")->Do(
174   - SQL => "delete from queue_service where service_id = ?",
175   - Bind => [ \$Param{ServiceID} ]
176   - );
177   -
178   - for my $queue (@Queues) {
179   - $Kernel::OM->Get("Kernel::System::DB")->Do(
180   - SQL => "insert into queue_service(queue_id,service_id) values (?,?)",
181   - Bind => [\$queue, \$Param{ServiceID}]
182   - );
183   -
184   - }
185   -}
186   -
187   -
188   -1;
QueueService.sopm
... ... @@ -1,44 +0,0 @@
1   -<?xml version="1.0" encoding="utf-8" ?>
2   -<otrs_package version="1.0">
3   - <Name>QueueService</Name>
4   - <Version>1.2.0</Version>
5   - <Framework>5.0.x</Framework>
6   - <Vendor>SeTIC</Vendor>
7   - <URL>http://setic.ufsc.br</URL>
8   - <License>GPLv2</License>
9   -
10   - <ChangeLog Version="1.0.0" Date="2014-06-01">First Version</ChangeLog>
11   - <ChangeLog Version="1.1.0" Date="2014-01-06">Support for OTRS 4</ChangeLog>
12   - <ChangeLog Version="1.2.0" Date="2014-01-06">Support for OTRS 5.0.x</ChangeLog>
13   -
14   - <Description>Services per queue association</Description>
15   -
16   - <BuildDate>?</BuildDate>
17   - <BuildHost>?</BuildHost>
18   -
19   - <IntroInstall Type="post" Title="Thank you"><![CDATA[
20   - Module installed successfully!<BR/><BR/>
21   - ]]></IntroInstall>
22   -
23   - <Filelist>
24   - <File Permission="644" Location="Kernel/Config/Files/QueueService.xml"></File>
25   - <File Permission="644" Location="Kernel/Language/pt_BR_QueueService.pm"></File>
26   - <File Permission="644" Location="Kernel/Modules/QueueService.pm"></File>
27   - <File Permission="644" Location="Kernel/Output/HTML/Templates/Standard/QueueService.tt"></File>
28   - <File Permission="644" Location="Kernel/Output/HTML/Templates/Standard/QueueServiceChange.tt"></File>
29   - <File Permission="644" Location="Kernel/System/QueueService.pm"></File>
30   - </Filelist>
31   - <DatabaseInstall>
32   - <TableCreate Name="queue_service">
33   - <Column Name="id" Required="true" PrimaryKey="true" AutoIncrement="true" Type="int"/>
34   - <Column Name="service_id" Required="true" Type="int"/>
35   - <Column Name="queue_id" Required="true" Type="int"/>
36   - <ForeignKey ForeignTable="service">
37   - <Reference Local="service_id" Foreign="id"/>
38   - </ForeignKey>
39   - <ForeignKey ForeignTable="queue">
40   - <Reference Local="queue_id" Foreign="id"/>
41   - </ForeignKey>
42   - </TableCreate>
43   - </DatabaseInstall>
44   -</otrs_package>
src/Kernel/Config/Files/XML/QueueService.xml 0 → 100755
... ... @@ -0,0 +1,67 @@
  1 +<?xml version="1.0" encoding="UTF-8" ?>
  2 +<otrs_config init="Application" version="2.0">
  3 + <Setting Name="Frontend::Module###QueueService" Required="0" Valid="1">
  4 + <Description Lang="en">Frontend module registration for the service per queue. Support module used by other modules. Allows associating services and queues.</Description>
  5 + <Description Lang="pt_BR">Registro do módulo de frontend de serviços por fila. Módulo de suporte usado por outros módulos. Permite associar serviços e filas.</Description>
  6 + <Navigation>Frontend::Admin::ModuleRegistration</Navigation>
  7 + <Value>
  8 + <Item ValueType="FrontendRegistration">
  9 + <Hash>
  10 + <Item Key="GroupRo">
  11 + <Array>
  12 + </Array>
  13 + </Item>
  14 + <Item Key="Group">
  15 + <Array>
  16 + <Item>admin</Item>
  17 + </Array>
  18 + </Item>
  19 + <Item Key="Description">Admin</Item>
  20 + <Item Key="Title" Lang="en">Services per queue</Item>
  21 + <Item Key="Title" Lang="pt_BR">Serviços por fila</Item>
  22 + <Item Key="NavBarName">Admin</Item>
  23 + </Hash>
  24 + </Item>
  25 + </Value>
  26 + </Setting>
  27 + <Setting Name="Frontend::Navigation###QueueService###002-QueueService" Required="0" Valid="0">
  28 + <Description Lang="en">Main menu item registration.</Description>
  29 + <Description Lang="pt_BR">Registro do item do menu principal.</Description>
  30 + <Navigation>Frontend::Admin::ModuleRegistration::MainMenu</Navigation>
  31 + <Value>
  32 + <Array>
  33 + <DefaultItem ValueType="FrontendNavigation">
  34 + <Hash>
  35 + </Hash>
  36 + </DefaultItem>
  37 + </Array>
  38 + </Value>
  39 + </Setting>
  40 + <Setting Name="Frontend::NavigationModule###QueueService" Required="0" Valid="1">
  41 + <Description Lang="en">Admin area navigation for the agent interface.</Description>
  42 + <Description Lang="pt_BR">Área administrativa para a interface de agente.</Description>
  43 + <Navigation>Frontend::Admin::ModuleRegistration::AdminOverview</Navigation>
  44 + <Value>
  45 + <Hash>
  46 + <Item Key="Group">
  47 + <Array>
  48 + <Item>admin</Item>
  49 + </Array>
  50 + </Item>
  51 + <Item Key="GroupRo">
  52 + <Array>
  53 + </Array>
  54 + </Item>
  55 + <Item Key="Module">Kernel::Output::HTML::NavBar::ModuleAdmin</Item>
  56 + <Item Key="Name" Lang="en">Services per queue</Item>
  57 + <Item Key="Name" Lang="pt_BR">Serviços por fila</Item>
  58 + <Item Key="Block">Ticket</Item>
  59 + <Item Key="Description" Lang="en">Create and manages services per queue</Item>
  60 + <Description Lang="pt_BR">Cria e gerencia serviços por fila</Description>
  61 + <Item Key="IconBig"></Item>
  62 + <Item Key="IconSmall"></Item>
  63 + </Hash>
  64 + </Value>
  65 + </Setting>
  66 +
  67 +</otrs_config>
... ...
src/Kernel/Language/pt_BR_QueueService.pm 0 → 100644
... ... @@ -0,0 +1,28 @@
  1 +# --
  2 +# Kernel/Modules/pt_BR_QueueService.pm - module to associate services per queue
  3 +#
  4 +# Copyright (C) 2014-2018 - SeTIC - UFSC - http://setic.ufsc.br/
  5 +#
  6 +# Version 2015-06-01 - Adjustments for OTRS 4
  7 +# Version 2018-01-03 - Adjustments for OTRS 6
  8 +#
  9 +# --
  10 +# This software comes with ABSOLUTELY NO WARRANTY. For details, see
  11 +# the enclosed file COPYING for license information (AGPL). If you
  12 +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
  13 +# --
  14 +package Kernel::Language::pt_BR_QueueService;
  15 +
  16 +use strict;
  17 +use warnings;
  18 +use utf8;
  19 +
  20 +sub Data {
  21 + my $Self = shift;
  22 + $Self->{Translation}->{'Services per queue'} = 'Serviços por fila';
  23 + $Self->{Translation}->{'Create and manages services per queue'} = 'Cria e gerencia serviços por fila';
  24 +
  25 + return 1;
  26 +}
  27 +
  28 +1;
0 29 \ No newline at end of file
... ...
src/Kernel/Modules/QueueService.pm 0 → 100644
... ... @@ -0,0 +1,219 @@
  1 +# --
  2 +# Kernel/Modules/QueueService.pm - frontend module
  3 +#
  4 +# Copyright (C) 2014-2018 - SeTIC - UFSC - http://setic.ufsc.br/
  5 +#
  6 +# Version 2016-06-01 - Adjustments for OTRS 4
  7 +# Version 2018-01-03 - Adjustments for OTRS 6
  8 +#
  9 +package Kernel::Modules::QueueService;
  10 +
  11 +use strict;
  12 +use warnings;
  13 +use Data::Dumper;
  14 +
  15 +our @ObjectDependencies = (
  16 + "Kernel::System::Web::Request",
  17 + "Kernel::System::DB",
  18 + "Kernel::System::Ticket",
  19 + "Kernel::Output::HTML::Layout",
  20 + "Kernel::System::Log",
  21 + "Kernel::System::Queue",
  22 + "Kernel::Config",
  23 + "Kernel::System::Encode",
  24 + "Kernel::System::Main",
  25 + "Kernel::System::QueueService",
  26 + "Kernel::System::Service"
  27 +);
  28 +
  29 +sub new {
  30 + my ( $Type, %Param ) = @_;
  31 +
  32 + # allocate new hash for object
  33 + my $Self = {%Param};
  34 + bless( $Self, $Type );
  35 +
  36 + return $Self;
  37 +}
  38 +
  39 +sub Run {
  40 + my ( $Self, %Param ) = @_;
  41 +
  42 + my $ParamObject = $Kernel::OM->Get("Kernel::System::Web::Request");
  43 +
  44 + my $SubAction = $ParamObject->GetParam( Param => "Subaction" );
  45 +
  46 + if ( $SubAction eq "ServiceEdit" ) {
  47 + return $Self->ShowChangeService( ID => $ParamObject->GetParam( Param => "ID" ) );
  48 + }
  49 + elsif ( $SubAction eq "QueueEdit" ) {
  50 + return $Self->ShowChangeQueue( ID => $ParamObject->GetParam( Param => "ID" ) );
  51 + }
  52 + elsif ( $SubAction eq "ChangeService" ) {
  53 + $Self->ChangeService();
  54 + return $Self->ShowOverview();
  55 + }
  56 + elsif ( $SubAction eq "ChangeQueue" ) {
  57 + $Self->ChangeQueue();
  58 + return $Self->ShowOverview();
  59 + }
  60 + else {
  61 + return $Self->ShowOverview();
  62 + }
  63 +}
  64 +
  65 +sub ShowOverview() {
  66 + my ( $Self, %Param ) = @_;
  67 + my %Data = ();
  68 +
  69 + my %Queues = $Kernel::OM->Get("Kernel::System::Queue")->QueueList( Valid => 1 );
  70 + my %Services = $Kernel::OM->Get("Kernel::System::Service")->ServiceList( UserID => 1 );
  71 + my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
  72 + my $LanguageObject = $Kernel::OM->Get("Kernel::Language");
  73 +
  74 + foreach my $service ( sort { uc( $Services{$a} ) cmp uc( $Services{$b} ) } keys %Services ) {
  75 + $LayoutObject->Block(
  76 + Name => 'ListService',
  77 + Data => {
  78 + ServiceID => $service,
  79 + ServiceName => $Services{$service},
  80 + }
  81 + );
  82 + }
  83 +
  84 + foreach my $queue ( sort { uc( $Queues{$a} ) cmp uc( $Queues{$b} ) } keys %Queues ) {
  85 + $LayoutObject->Block(
  86 + Name => 'ListQueue',
  87 + Data => {
  88 + QueueID => $queue,
  89 + QueueName => $Queues{$queue},
  90 + }
  91 + );
  92 + }
  93 +
  94 + my $Output = $LayoutObject->Header( Title => $LanguageObject->Translate("Services per queue") );
  95 + $Output .= $LayoutObject->NavigationBar();
  96 + $Output .= $LayoutObject->Output(
  97 + Data => \%Data,
  98 + TemplateFile => 'QueueService'
  99 + );
  100 +
  101 + $Output .= $LayoutObject->Footer();
  102 + return $Output;
  103 +}
  104 +
  105 +=item ShowChangeService()
  106 +
  107 +Show view to change queues associated to a service
  108 +
  109 +=cut
  110 +sub ShowChangeService() {
  111 + my ( $Self, %Param ) = @_;
  112 + my %Data = ();
  113 + my %Service = $Kernel::OM->Get("Kernel::System::Service")->ServiceGet( ServiceID => $Param{ID}, UserID => 1 );
  114 + my %QueuesService = $Kernel::OM->Get("Kernel::System::QueueService")->GetQueueList( ServiceID => $Param{ID} );
  115 + my %Queues = $Kernel::OM->Get("Kernel::System::Queue")->QueueList( Valid => 1 );
  116 + my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
  117 + my $LanguageObject = $Kernel::OM->Get("Kernel::Language");
  118 +
  119 + $Data{Type} = "Queue";
  120 + $Data{Filter} = "Service";
  121 + $Data{VisibleNeType} = "Service";
  122 + $Data{Name} = $Service{Name};
  123 + $Data{ID} = $Service{ServiceID};
  124 +
  125 + $LayoutObject->Block(
  126 + Name => 'ChangeHeader',
  127 + Data => \%Data
  128 + );
  129 +
  130 + foreach my $queue ( sort { uc( $Queues{$a} ) cmp uc( $Queues{$b} ) } keys %Queues ) {
  131 + $LayoutObject->Block(
  132 + Name => 'ChangeRow',
  133 + Data => {
  134 + Type => "Queue",
  135 + ID => $queue,
  136 + Name => $Queues{$queue},
  137 + Selected => ( $QueuesService{$queue} ? 'checked="checked"' : '' )
  138 + }
  139 + );
  140 + }
  141 +
  142 + my $Output =
  143 + $LayoutObject->Header( Title => $LanguageObject->Translate("Services per queue") );
  144 + $Output .= $LayoutObject->NavigationBar();
  145 + $Output .= $LayoutObject->Output(
  146 + Data => \%Data,
  147 + TemplateFile => 'QueueServiceChange'
  148 + );
  149 +
  150 + $Output .= $LayoutObject->Footer();
  151 + return $Output;
  152 +}
  153 +
  154 +=item ShowChangeQueue()
  155 +
  156 +Show view to change services associated to a queue
  157 +
  158 +=cut
  159 +sub ShowChangeQueue() {
  160 + my ( $Self, %Param ) = @_;
  161 + my %Data = ();
  162 + my %Queue = $Kernel::OM->Get("Kernel::System::Queue")->QueueGet( ID => $Param{ID} );
  163 + my %ServicesQueue = $Kernel::OM->Get("Kernel::System::QueueService")->GetServiceList( QueueID => $Param{ID} );
  164 + my %Services = $Kernel::OM->Get("Kernel::System::Service")->ServiceList( UserID => 1 );
  165 + my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
  166 + my $LanguageObject = $Kernel::OM->Get("Kernel::Language");
  167 +
  168 + $Data{Type} = "Service";
  169 + $Data{Filter} = "Queue";
  170 + $Data{VisibleNeType} = "Queue";
  171 + $Data{Name} = $Queue{Name};
  172 + $Data{ID} = $Queue{QueueID};
  173 +
  174 + $LayoutObject->Block(
  175 + Name => 'ChangeHeader',
  176 + Data => \%Data
  177 + );
  178 +
  179 + foreach my $service ( sort { uc( $Services{$a} ) cmp uc( $Services{$b} ) } keys %Services ) {
  180 + $LayoutObject->Block(
  181 + Name => 'ChangeRow',
  182 + Data => {
  183 + Type => "Service",
  184 + ID => $service,
  185 + Name => $Services{$service},
  186 + Selected => ( $ServicesQueue{$service} ? 'checked="checked"' : '' )
  187 + }
  188 + );
  189 + }
  190 +
  191 + my $Output =
  192 + $LayoutObject->Header( Title => $LanguageObject->Translate("Services per queue") );
  193 + $Output .= $LayoutObject->NavigationBar();
  194 + $Output .= $LayoutObject->Output(
  195 + Data => \%Data,
  196 + TemplateFile => 'QueueServiceChange'
  197 + );
  198 +
  199 + $Output .= $LayoutObject->Footer();
  200 + return $Output;
  201 +
  202 +}
  203 +
  204 +sub ChangeService() {
  205 + my ( $Self, %Param ) = @_;
  206 + my @queueIDs = $Kernel::OM->Get("Kernel::System::Web::Request")->GetArray( Param => 'Queue' );
  207 + my $id = $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => 'ID' );
  208 + $Kernel::OM->Get("Kernel::System::QueueService")->SetServiceQueues(ServiceID => $id, Queues => \@queueIDs);
  209 +}
  210 +
  211 +sub ChangeQueue() {
  212 + my ( $Self, %Param ) = @_;
  213 + my @serviceIDs = $Kernel::OM->Get("Kernel::System::Web::Request")->GetArray( Param => 'Service' );
  214 + my $id = $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => 'ID' );
  215 + $Kernel::OM->Get("Kernel::System::QueueService")->SetQueueServices(QueueID => $id, Services => \@serviceIDs);
  216 +
  217 +}
  218 +
  219 +1;
0 220 \ No newline at end of file
... ...
src/Kernel/Output/HTML/Templates/Standard/QueueService.tt 0 → 100644
... ... @@ -0,0 +1,88 @@
  1 +# --
  2 +# Kernel/Output/HTML/Standard/QueueService.tt - overview
  3 +#
  4 +# Copyright (C) (2014-2018) - SeTIC - UFSC - http://setic.ufsc.br/
  5 +#
  6 +# Version 2016-06-01 - Adjusts for OTRS 4
  7 +# Version 2018-01-03 - Adjusts for OTRS 6
  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 +<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst">
  14 + <h1>[% Translate("Services per queue") | html %]</h1>
  15 +
  16 + [% BreadcrumbPath = [
  17 + {
  18 + Name => Translate('Services per queue'),
  19 + Link => Env("Action"),
  20 + },
  21 + ]
  22 + %]
  23 + [% INCLUDE "Breadcrumb.tt" Path = BreadcrumbPath %]
  24 +
  25 + <div class="SidebarColumn">
  26 +
  27 + <div class="WidgetSimple">
  28 + <div class="Header">
  29 + <h2>[% Translate("Actions") | html %]</h2>
  30 + </div>
  31 + <div class="Content">
  32 + <ul class="ActionList">
  33 + <li>
  34 + <a href="[% Env("Baselink") %]Action=[% Env("Action") %]" class="CallForAction"><span>[% Translate("Go to overview") | html %]</span></a>
  35 + </li>
  36 + </ul>
  37 + </div>
  38 + </div>
  39 +
  40 +[% RenderBlockStart("serviceFilter") %]
  41 + <div class="WidgetSimple">
  42 + <div class="Header">
  43 + <h2><label for="FilterServices">[% Translate("Services") | html %]</label></h2>
  44 + </div>
  45 + <div class="Content">
  46 + <input type="text" id="FilterUsers" class="W50pc" name="FilterUser" value="" title="[% Translate("Service") | html %]" />
  47 + </div>
  48 + </div>
  49 +[% RenderBlockEnd("serviceFilter") %]
  50 +[% RenderBlockStart("queueFilter") %]
  51 + <div class="WidgetSimple">
  52 + <div class="Header">
  53 + <h2><label for="FilterQueues">[% Translate("Queues") | html %]</label></h2>
  54 + </div>
  55 + <div class="Content">
  56 + <input type="text" id="FilterGroups" class="W50pc" name="FilterGroups" value="" title="[% Translate("Queue") | html %]"/>
  57 + </div>
  58 + </div>
  59 +[% RenderBlockEnd("queueFilter") %]
  60 + </div>
  61 +
  62 + <div class="ContentColumn">
  63 + <div class="WidgetSimple">
  64 +
  65 + <div class="Header">
  66 + <h2>[% Translate("Overview") | html %]</h2>
  67 + </div>
  68 + <div class="Content LayoutGrid ColumnsWithSpacing">
  69 + <div class="Size1of2">
  70 + <ul class="Tablelike" id="Services">
  71 + <li class="Header">[% Translate("Services") | html %]</li>
  72 + <li class="FilterMessage Hidden">[% Translate("No matches found.") | html %]</li>
  73 +[% RenderBlockStart("ListService") %]
  74 + <li><a href="[% Env("Baselink") %]Action=[% Env("Action") %];Subaction=ServiceEdit;ID=[% Data.ServiceID | uri %]" class="AsBlock">[% Data.ServiceName | html %]</a></li>
  75 +[% RenderBlockEnd("ListService") %]
  76 + </ul>
  77 + </div>
  78 + <div class="Size1of2">
  79 + <ul class="Tablelike" id="Queues">
  80 + <li class="Header">[% Translate("Queues") | html %]</li>
  81 + <li class="FilterMessage Hidden">[% Translate("No matches found.") | html %]</li>
  82 +[% RenderBlockStart("ListQueue") %]
  83 + <li><a href="[% Env("Baselink") %]Action=[% Env("Action") %];Subaction=QueueEdit;ID=[% Data.QueueID | uri %]" class="AsBlock">[% Data.QueueName | html %]</a></li>
  84 +[% RenderBlockEnd("ListQueue") %]
  85 + </ul>
  86 + </div>
  87 + <div class="Clear"></div>
  88 + </div>
0 89 \ No newline at end of file
... ...
src/Kernel/Output/HTML/Templates/Standard/QueueServiceChange.tt 0 → 100644
... ... @@ -0,0 +1,123 @@
  1 +# --
  2 +# Kernel/Output/HTML/Standard/QueueServiceChange.tt - edit
  3 +# Copyright (C) (2014) SeTIC - UFSC - http://setic.ufsc.br/
  4 +# Version 06/01/2015 - Adjusts for OTRS 4
  5 +#
  6 +# This software comes with ABSOLUTELY NO WARRANTY. For details, see
  7 +# the enclosed file COPYING for license information (AGPL). If you
  8 +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
  9 +# --
  10 +<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst">
  11 + <h1>[% Translate("Services and queues") | html %]</h1>
  12 +
  13 + [% BreadcrumbPath = [
  14 + {
  15 + Name => Translate('Services per queue'),
  16 + Link => Env("Action"),
  17 + },
  18 + ]
  19 + %]
  20 +
  21 + [% IF Data.Type == "Service" %]
  22 + [% USE EditTitle = String(Translate("Customizing services for queue")) %]
  23 + [% BreadcrumbPath.push({ Name => EditTitle.append( ' ', Data.Name ) }) %]
  24 + [% END %]
  25 + [% IF Data.Type == "Queue" %]
  26 + [% USE EditTitle = String(Translate("Customizing queues for service")) %]
  27 + [% BreadcrumbPath.push({ Name => EditTitle.append( ' ', Data.Name ) }) %]
  28 + [% END %]
  29 +
  30 + [% INCLUDE "Breadcrumb.tt" Path = BreadcrumbPath %]
  31 +
  32 + <div class="SidebarColumn">
  33 + <div class="WidgetSimple">
  34 + <div class="Header">
  35 + <h2>[% Translate("Actions") | html %]</h2>
  36 + </div>
  37 + <div class="Content">
  38 + <ul class="ActionList">
  39 + <li>
  40 + <a href="[% Env("Baselink") %]Action=[% Env("Action") %]" class="CallForAction"><span>[% Translate("Go to overview") | html %]</span></a>
  41 + </li>
  42 + </ul>
  43 + </div>
  44 + </div>
  45 + <div class="WidgetSimple">
  46 + <div class="Header">
  47 + <h2>
  48 + <label for="Filter">[% Translate("Filter") | html %]</label>
  49 + </h2>
  50 + </div>
  51 + <div class="Content">
  52 + <input type="text" id="Filter" class="W50pc" name="Filter" value="" title="[% Translate("Filter") | html %]" />
  53 + </div>
  54 + </div>
  55 + </div>
  56 +
  57 + <div class="ContentColumn">
  58 + <div class="WidgetSimple">
  59 + <div class="Header">
  60 + <h2>
  61 +[% RenderBlockStart("ChangeHeaderService") %]
  62 + [% Translate("Select queues for the service") | html %]
  63 +[% RenderBlockEnd("ChangeHeaderService") %]
  64 +[% RenderBlockStart("ChangeHeaderQueue") %]
  65 + [% Translate("Select services for the queue") | html %]
  66 +[% RenderBlockEnd("ChangeHeaderQueue") %]
  67 + [% Data.Name | html %]
  68 + </h2>
  69 + </div>
  70 + <div class="Content ">
  71 + <form action="[% Env("CGIHandle") %]" method="post" name="matrix">
  72 + <input type="hidden" name="Action" value="[% Env("Action") %]"/>
  73 + <input type="hidden" name="Subaction" value="Change[% Data.VisibleNeType | html %]"/>
  74 + <input type="hidden" name="ID" value="[% Data.ID | html %]"/>
  75 + <table class="DataTable VariableWidth" id="ServicesQueues">
  76 + <thead>
  77 + <tr>
  78 + <th>[% Translate(Data.VisibleNeType) | html %]</th>
  79 +[% RenderBlockStart("ChangeHeader") %]
  80 + <th class="Center [% Data.Mark | html %]">
  81 + <input type="checkbox" name="[% Data.Type | html %]" id="SelectAll[% Data.Type | html %]" title="[% Translate("Toggle active state for all") | html %]" value="" />
  82 + [% Translate("Active") | html %]
  83 + </th>
  84 +[% WRAPPER JSOnDocumentComplete %]
  85 +<script type="text/javascript">//<![CDATA[
  86 + Core.Form.InitSelectAllCheckboxes($('table td input:checkbox[name=[% Data.Type | html %]]'), $('#SelectAll[% Data.Type | html %]'));
  87 + $('input:checkbox[name=[% Data.Type | html %]]').bind('click', function () {
  88 + Core.Form.SelectAllCheckboxes($(this), $('#SelectAll[% Data.Type | html %]'));
  89 + });
  90 +//]]></script>
  91 +[% END %]
  92 +[% RenderBlockEnd("ChangeHeader") %]
  93 + </tr>
  94 + </thead>
  95 + <tbody>
  96 +[% RenderBlockStart("ChangeRow") %]
  97 + <tr>
  98 + <td>[% Data.Name | html %]</td>
  99 + <td class="[% Data.Mark | html %]">
  100 + <input type="checkbox" name="[% Data.Type | html %]" title="[% Translate("Toggle active state for %s", Data.Name) | html %]" value="[% Data.ID | html %]" [% Data.Selected %]/>
  101 + </td>
  102 + </tr>
  103 +[% RenderBlockEnd("ChangeRow") %]
  104 + </tbody>
  105 + </table>
  106 + <div class="Field SpacingTop">
  107 + <button class="Primary" type="submit" value="[% Translate("Submit") | html %]">[% Translate("Submit") | html %]</button>
  108 + [% Translate("or") | html %]
  109 + <a href="[% Env("Baselink") %]Action=[% Env("Action") %]">[% Translate("Cancel") | html %]</a>
  110 + </div>
  111 + <div class="Clear"></div>
  112 + </form>
  113 + </div>
  114 + </div>
  115 + </div>
  116 + <div class="Clear"></div>
  117 +</div>
  118 +
  119 +[% WRAPPER JSOnDocumentComplete %]
  120 +<script type="text/javascript">//<![CDATA[
  121 + Core.UI.Table.InitTableFilter($('#Filter'), $('#ServicesQueues'));
  122 +//]]></script>
  123 +[% END %]
... ...
src/Kernel/System/QueueService.pm 0 → 100644
... ... @@ -0,0 +1,190 @@
  1 +# --
  2 +# Kernel/System/QueueService.pm - core module
  3 +# Manages Services association to queues
  4 +#
  5 +# Copyright (C) 2014-2018 - SeTIC - UFSC - http://setic.ufsc.br/
  6 +#
  7 +# Version 2016-06-01 - Adjustments for OTRS 4
  8 +# Version 2018-01-03 - Adjustments for OTRS 6
  9 +#
  10 +# This software comes with ABSOLUTELY NO WARRANTY. For details, see
  11 +# the enclosed file COPYING for license information (AGPL). If you
  12 +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
  13 +# --
  14 +#
  15 +package Kernel::System::QueueService;
  16 +
  17 +use strict;
  18 +use warnings;
  19 +use Data::Dumper;
  20 +
  21 +our @ObjectDependencies = (
  22 + "Kernel::Output::HTML::Layout",
  23 + "Kernel::System::DB"
  24 +);
  25 +
  26 +sub new {
  27 + my ( $Type, %Param ) = @_;
  28 +
  29 + # allocate new hash for object
  30 + my $Self = {%Param};
  31 + bless( $Self, $Type );
  32 +
  33 + return $Self;
  34 +}
  35 +
  36 +=item GetServiceList()
  37 +
  38 +Get list of services for a queue
  39 +
  40 + my %{service_id}{QueueName} = $QueueServiceObject->GetServiceList(
  41 + QueueID => 123,
  42 + );
  43 +
  44 +=cut
  45 +sub GetServiceList {
  46 + my ( $Self, %Param ) = @_;
  47 + my %result = ();
  48 +
  49 + for (qw(QueueID)) {
  50 + if ( !$Param{$_} ) {
  51 + $Kernel::OM->Get("Kernel::Output::HTML::Layout")->FatalError( Message => Dumper( \%Param ) . "got no $_!" );
  52 + }
  53 + }
  54 +
  55 + $Kernel::OM->Get("Kernel::System::DB")->Prepare(
  56 + SQL => "
  57 + select
  58 + a.service_id id,
  59 + b.name Name
  60 + from
  61 + queue_service a
  62 + inner join service b on(b.id = a.service_id)
  63 + where
  64 + a.queue_id = ?",
  65 + Bind => [ \$Param{QueueID} ]
  66 + );
  67 +
  68 + while ( my @row = $Kernel::OM->Get("Kernel::System::DB")->FetchrowArray() ) {
  69 + $result{ $row[0] } = $row[1];
  70 + }
  71 +
  72 + return %result;
  73 +}
  74 +
  75 +=item GetQueueList()
  76 +
  77 +Get list of queues for a service
  78 +
  79 + my %{queue_id}{QueueName} = $QueueServiceObject->GetQueueList(
  80 + ServiceID => 123,
  81 + );
  82 +
  83 +=cut
  84 +sub GetQueueList {
  85 + my ( $Self, %Param ) = @_;
  86 + my %result = ();
  87 +
  88 + for (qw(ServiceID)) {
  89 + if ( !$Param{$_} ) {
  90 + $Kernel::OM->Get("Kernel::Output::HTML::Layout")->FatalError( Message => Dumper( \%Param ) . "got no $_!" );
  91 + }
  92 + }
  93 +
  94 + $Kernel::OM->Get("Kernel::System::DB")->Prepare(
  95 + SQL => "
  96 + select
  97 + a.queue_id id,
  98 + b.name Name
  99 + from
  100 + queue_service a
  101 + inner join queue b on(b.id = a.queue_id)
  102 + where
  103 + a.service_id = ?",
  104 + Bind => [ \$Param{ServiceID} ]
  105 + );
  106 +
  107 + while ( my @row = $Kernel::OM->Get("Kernel::System::DB")->FetchrowArray() ) {
  108 + $result{ $row[0] } = $row[1];
  109 + }
  110 +
  111 + return %result;
  112 +}
  113 +
  114 +
  115 +=item SetQueueServices()
  116 +
  117 +Defines the list of services for a queue
  118 +
  119 + $QueueServiceObject->SetQueueServices(
  120 + QueueID => 123,
  121 + Services => @ServiceIDs
  122 + );
  123 +
  124 +=cut
  125 +sub SetQueueServices {
  126 + my ( $Self, %Param ) = @_;
  127 + my %result = ();
  128 +
  129 + for (qw(QueueID Services)) {
  130 + if ( !$Param{$_} ) {
  131 + $Kernel::OM->Get("Kernel::Output::HTML::Layout")->FatalError( Message => Dumper( \%Param ) . "got no $_!" );
  132 + }
  133 + }
  134 +
  135 + my $QueueID = $Param{"QueueID"};
  136 + my @Services = @{$Param{"Services"}};
  137 +
  138 + $Kernel::OM->Get("Kernel::System::DB")->Do(
  139 + SQL => "delete from queue_service where queue_id = ?",
  140 + Bind => [ \$Param{QueueID} ]
  141 + );
  142 +
  143 + for my $service (@Services) {
  144 + $Kernel::OM->Get("Kernel::System::DB")->Do(
  145 + SQL => "insert into queue_service(queue_id,service_id) values (?,?)",
  146 + Bind => [\$Param{QueueID}, \$service]
  147 + );
  148 +
  149 + }
  150 +}
  151 +
  152 +=item SetServiceQueues()
  153 +
  154 +Defines the list of services for a queue
  155 +
  156 + $QueueServiceObject->SetServiceQueues(
  157 + ServiceID => 123,
  158 + Queues => @ServiceIDs
  159 + );
  160 +
  161 +=cut
  162 +sub SetServiceQueues {
  163 + my ( $Self, %Param ) = @_;
  164 + my %result = ();
  165 +
  166 + for (qw(ServiceID Queues)) {
  167 + if ( !$Param{$_} ) {
  168 + $Kernel::OM->Get("Kernel::Output::HTML::Layout")->FatalError( Message => Dumper( \%Param ) . "got no $_!" );
  169 + }
  170 + }
  171 +
  172 + my $ServiceID = $Param{"ServiceID"};
  173 + my @Queues = @{$Param{"Queues"}};
  174 +
  175 + $Kernel::OM->Get("Kernel::System::DB")->Do(
  176 + SQL => "delete from queue_service where service_id = ?",
  177 + Bind => [ \$Param{ServiceID} ]
  178 + );
  179 +
  180 + for my $queue (@Queues) {
  181 + $Kernel::OM->Get("Kernel::System::DB")->Do(
  182 + SQL => "insert into queue_service(queue_id,service_id) values (?,?)",
  183 + Bind => [\$queue, \$Param{ServiceID}]
  184 + );
  185 +
  186 + }
  187 +}
  188 +
  189 +
  190 +1;
... ...
src/QueueService.sopm 0 → 100755
... ... @@ -0,0 +1,52 @@
  1 +<?xml version="1.0" encoding="utf-8" ?>
  2 +<otrs_package version="1.0">
  3 + <Name>QueueService</Name>
  4 + <Version>1.3.0</Version>
  5 + <Framework>6.0.x</Framework>
  6 + <Vendor>SeTIC</Vendor>
  7 + <URL>http://setic.ufsc.br</URL>
  8 + <License>AGPL</License>
  9 +
  10 + <ChangeLog Version="1.0.0" Date="2014-06-01">First Version</ChangeLog>
  11 + <ChangeLog Version="1.1.0" Date="2015-01-06">Support for OTRS 4</ChangeLog>
  12 + <ChangeLog Version="1.2.0" Date="2016-01-06">Support for OTRS 5.0.x</ChangeLog>
  13 + <ChangeLog Version="1.3.0" Date="2017-01-03">Support for OTRS 6.0.x</ChangeLog>
  14 +
  15 + <Description>Services per queue association. Support module used by other modules.</Description>
  16 + <Description Lang="pt_BR">Associação entre serviços e filas. Módulo de suporte utilizado por outros módulos.</Description>
  17 +
  18 +
  19 + <BuildDate>?</BuildDate>
  20 + <BuildHost>?</BuildHost>
  21 +
  22 + <IntroInstall Type="post" Title="Thank you"><![CDATA[
  23 + Module installed successfully!<BR/><BR/>
  24 + ]]></IntroInstall>
  25 +
  26 + <IntroInstall Type="post" Lang="pt_BR" Title="Obrigado"><![CDATA[
  27 + Módulo instalado com sucesso!<BR/><BR/>
  28 + ]]></IntroInstall>
  29 +
  30 + <Filelist>
  31 + <File Permission="644" Location="Kernel/Config/Files/XML/QueueService.xml"></File>
  32 + <File Permission="644" Location="Kernel/Language/pt_BR_QueueService.pm"></File>
  33 + <File Permission="644" Location="Kernel/Modules/QueueService.pm"></File>
  34 + <File Permission="644" Location="Kernel/Output/HTML/Templates/Standard/QueueService.tt"></File>
  35 + <File Permission="644" Location="Kernel/Output/HTML/Templates/Standard/QueueServiceChange.tt"></File>
  36 + <File Permission="644" Location="Kernel/System/QueueService.pm"></File>
  37 + <File Permission="644" Location="var/httpd/htdocs/js/QueueService.js"></File>
  38 + </Filelist>
  39 + <DatabaseInstall>
  40 + <TableCreate Name="queue_service">
  41 + <Column Name="id" Required="true" PrimaryKey="true" AutoIncrement="true" Type="int"/>
  42 + <Column Name="service_id" Required="true" Type="int"/>
  43 + <Column Name="queue_id" Required="true" Type="int"/>
  44 + <ForeignKey ForeignTable="service">
  45 + <Reference Local="service_id" Foreign="id"/>
  46 + </ForeignKey>
  47 + <ForeignKey ForeignTable="queue">
  48 + <Reference Local="queue_id" Foreign="id"/>
  49 + </ForeignKey>
  50 + </TableCreate>
  51 + </DatabaseInstall>
  52 +</otrs_package>
... ...
src/var/httpd/htdocs/js/QueueService.js 0 → 100755
... ... @@ -0,0 +1,24 @@
  1 +/**
  2 + * QueueService module
  3 + *
  4 + * Copyright (C) 2014-2018 - SeTIC - UFSC - http://setic.ufsc.br/
  5 + *
  6 + * Version 2018-01-03 - Conversion to JS Module, to support OTRS 6
  7 + *
  8 + */
  9 +var Core = Core || {};
  10 +Core.Agent = Core.Agent || {};
  11 +Core.Agent.Admin = Core.Agent.Admin || {};
  12 +
  13 +Core.Agent.Admin.QueueService = (function (TargetNS) {
  14 +
  15 + TargetNS.Init = function() {
  16 + Core.UI.Table.InitTableFilter($('#FilterServices'), $('#Services'));
  17 + Core.UI.Table.InitTableFilter($('#FilterQueues'), $('#Queues'));
  18 + }
  19 +
  20 + Core.Init.RegisterNamespace(TargetNS, 'APP_MODULE');
  21 +
  22 + return TargetNS;
  23 +
  24 +}(Core.Agent.Admin.QueueService || {}));
0 25 \ No newline at end of file
... ...