diff --git a/.project b/.project new file mode 100644 index 0000000..1ee937e --- /dev/null +++ b/.project @@ -0,0 +1,18 @@ + + + otrs-queue-service + + + otrs + + + + org.epic.perleditor.perlbuilder + + + + + + org.epic.perleditor.perlnature + + diff --git a/CreateOpm.sh b/CreateOpm.sh new file mode 100755 index 0000000..f4d7674 --- /dev/null +++ b/CreateOpm.sh @@ -0,0 +1,5 @@ +#!/bin/bash +LOCAL="$PWD" +cd /opt/otrs/bin +./otrs.PackageManager.pl -a build -p "$LOCAL"/QueueService.sopm -o "$LOCAL"/ +cd $LOCAL diff --git a/Kernel/Config/Files/QueueService.xml b/Kernel/Config/Files/QueueService.xml new file mode 100644 index 0000000..b5a2b15 --- /dev/null +++ b/Kernel/Config/Files/QueueService.xml @@ -0,0 +1,24 @@ + + + + + Frontend module registration for the service per queue + Ticket + Frontend::Admin::ModuleRegistration + + + admin + Admin + Services per queue + Admin + + Kernel::Output::HTML::NavBarModuleAdmin + Service per queue + Create and manage services per queue + Ticket + 900 + + + + + diff --git a/Kernel/Language/pt_BR_QueueService.pm b/Kernel/Language/pt_BR_QueueService.pm new file mode 100644 index 0000000..a8e3b82 --- /dev/null +++ b/Kernel/Language/pt_BR_QueueService.pm @@ -0,0 +1,22 @@ +# -- +# Kernel/Modules/pt_BR_NewTicketWizard.pm - frontend module for creating custom new ticket interfaces +# Translations +# +# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br) +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- +package Kernel::Language::pt_BR_NewTicketWizard; + +use strict; +use warnings; + +sub Data { + my $Self = shift; + + $Self->{Translation}->{'Services per queue'} = 'Serviços por fila'; + return 1; +} +1; \ No newline at end of file diff --git a/Kernel/Modules/QueueService.pm b/Kernel/Modules/QueueService.pm new file mode 100644 index 0000000..9bb83a1 --- /dev/null +++ b/Kernel/Modules/QueueService.pm @@ -0,0 +1,209 @@ +# -- +# Kernel/Modules/QueueService.pm - frontend module +# Copyright (C) (2014) (Rodrigo Gonçalves) (rodrigo.g@ufsc.br) +# -- +# $Id: writing-otrs-application.xml,v 1.1 2010/08/13 08:59:28 mg Exp $ +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- +# Autor: Carlos Rebelato +# 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; + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless( $Self, $Type ); + + # check needed objects + for ( + qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject EncodeObject MainObject) + ) + { + if ( !$Self->{$_} ) { + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); + } + } + + # create needed objects + $Self->{QueueServiceObject} = Kernel::System::QueueService->new(%Param); + $Self->{ServiceObject} = Kernel::System::Service->new(%Param); + + return $Self; +} + +sub Run { + my ( $Self, %Param ) = @_; + + my $SubAction = $Self->{ParamObject}->GetParam( Param => "Subaction" ); + + if ( $SubAction eq "ServiceEdit" ) { + return $Self->ShowChangeService( ID => $Self->{ParamObject}->GetParam( Param => "ID" ) ); + } + elsif ( $SubAction eq "QueueEdit" ) { + return $Self->ShowChangeQueue( ID => $Self->{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 = $Self->{QueueObject}->QueueList( Valid => 1 ); + my %Services = $Self->{ServiceObject}->ServiceList( UserID => 1 ); + + foreach my $service ( sort { uc( $Services{$a} ) cmp uc( $Services{$b} ) } keys %Services ) { + $Self->{LayoutObject}->Block( + Name => 'ListService', + Data => { + ServiceID => $service, + ServiceName => $Services{$service}, + } + ); + } + + foreach my $queue ( sort { uc( $Queues{$a} ) cmp uc( $Queues{$b} ) } keys %Queues ) { + $Self->{LayoutObject}->Block( + Name => 'ListQueue', + Data => { + QueueID => $queue, + QueueName => $Queues{$queue}, + } + ); + } + + my $Output = + $Self->{LayoutObject}->Header( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Services per queue") ); + $Output .= $Self->{LayoutObject}->NavigationBar(); + $Output .= $Self->{LayoutObject}->Output( + Data => \%Data, + TemplateFile => 'QueueService' + ); + + $Output .= $Self->{LayoutObject}->Footer(); + return $Output; +} + +sub ShowChangeService() { + my ( $Self, %Param ) = @_; + my %Data = (); + my %Service = $Self->{ServiceObject}->ServiceGet( ServiceID => $Param{ID}, UserID => 1 ); + my %QueuesService = $Self->{QueueServiceObject}->GetQueueList( ServiceID => $Param{ID} ); + my %Queues = $Self->{QueueObject}->QueueList( Valid => 1 ); + + $Data{Type} = "Queue"; + $Data{Filter} = "Service"; + $Data{VisibleNeType} = "Service"; + $Data{Name} = $Service{Name}; + $Data{ID} = $Service{ServiceID}; + + $Self->{LayoutObject}->Block( + Name => 'ChangeHeader', + Data => \%Data + ); + + foreach my $queue ( sort { uc( $Queues{$a} ) cmp uc( $Queues{$b} ) } keys %Queues ) { + $Self->{LayoutObject}->Block( + Name => 'ChangeRow', + Data => { + Type => "Queue", + ID => $queue, + Name => $Queues{$queue}, + Selected => ( $QueuesService{$queue} ? 'checked="checked"' : '' ) + } + ); + } + + my $Output = + $Self->{LayoutObject}->Header( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Services per queue") ); + $Output .= $Self->{LayoutObject}->NavigationBar(); + $Output .= $Self->{LayoutObject}->Output( + Data => \%Data, + TemplateFile => 'QueueServiceChange' + ); + + $Output .= $Self->{LayoutObject}->Footer(); + return $Output; +} + +sub ShowChangeQueue() { + my ( $Self, %Param ) = @_; + my %Data = (); + my %Queue = $Self->{QueueObject}->QueueGet( ID => $Param{ID} ); + my %ServicesQueue = $Self->{QueueServiceObject}->GetServiceList( QueueID => $Param{ID} ); + my %Services = $Self->{ServiceObject}->ServiceList( UserID => 1 ); + + $Data{Type} = "Service"; + $Data{Filter} = "Queue"; + $Data{VisibleNeType} = "Queue"; + $Data{Name} = $Queue{Name}; + $Data{ID} = $Queue{QueueID}; + + $Self->{LayoutObject}->Block( + Name => 'ChangeHeader', + Data => \%Data + ); + + foreach my $service ( sort { uc( $Services{$a} ) cmp uc( $Services{$b} ) } keys %Services ) { + $Self->{LayoutObject}->Block( + Name => 'ChangeRow', + Data => { + Type => "Service", + ID => $service, + Name => $Services{$service}, + Selected => ( $ServicesQueue{$service} ? 'checked="checked"' : '' ) + } + ); + } + + my $Output = + $Self->{LayoutObject}->Header( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Services per queue") ); + $Output .= $Self->{LayoutObject}->NavigationBar(); + $Output .= $Self->{LayoutObject}->Output( + Data => \%Data, + TemplateFile => 'QueueServiceChange' + ); + + $Output .= $Self->{LayoutObject}->Footer(); + return $Output; + +} + +sub ChangeService() { + my ( $Self, %Param ) = @_; + my @queueIDs = $Self->{ParamObject}->GetArray( Param => 'Queue' ); + my $id = $Self->{ParamObject}->GetParam( Param => 'ID' ); + $Self->{QueueServiceObject}->SetServiceQueues(ServiceID => $id, Queues => \@queueIDs); +} + + +sub ChangeQueue() { + my ( $Self, %Param ) = @_; + my @serviceIDs = $Self->{ParamObject}->GetArray( Param => 'Service' ); + my $id = $Self->{ParamObject}->GetParam( Param => 'ID' ); + $Self->{QueueServiceObject}->SetQueueServices(QueueID => $id, Services => \@serviceIDs); + +} \ No newline at end of file diff --git a/Kernel/Output/HTML/Standard/QueueService.dtl b/Kernel/Output/HTML/Standard/QueueService.dtl new file mode 100644 index 0000000..147ae8e --- /dev/null +++ b/Kernel/Output/HTML/Standard/QueueService.dtl @@ -0,0 +1,87 @@ +# -- +# Kernel/Output/HTML/Standard/QueueService.dtl - overview +# Copyright (C) (2014) (Rodrigo Gonçalves) (rodrigo.g@ufsc.br) +# -- +# $Id: writing-otrs-application.xml,v 1.1 2010/08/13 08:59:28 mg Exp $ +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- +
+

$Text{"Services per queue"}

+ +
+ +
+
+

$Text{"Actions"}

+
+ +
+ + +
+
+

+
+
+ +
+
+ + +
+
+

+
+
+ +
+
+ +
+ +
+
+ +
+

$Text{"Overview"}

+
+
+
+ +
+
+ +
+
+
+ + + + + + + \ No newline at end of file diff --git a/Kernel/Output/HTML/Standard/QueueServiceChange.dtl b/Kernel/Output/HTML/Standard/QueueServiceChange.dtl new file mode 100644 index 0000000..a4fe277 --- /dev/null +++ b/Kernel/Output/HTML/Standard/QueueServiceChange.dtl @@ -0,0 +1,95 @@ +
+

$Text{"Services and queues"}

+
+
+
+

$Text{"Actions"}

+
+ +
+
+
+

+ +

+
+
+ +
+
+
+ +
+
+
+

+ + $Text{"Select queues for the service"} + + + $Text{"Select services for the queue"} + + $QData{"Name"} +

+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
$Text{"$Data{"VisibleNeType"}"} + + $Text{"Active"} +
$QData{"Name"} + +
+
+ + $Text{"or"} + $Text{"Cancel"} +
+
+
+
+
+
+
+
+ + + + diff --git a/Kernel/System/QueueService.pm b/Kernel/System/QueueService.pm new file mode 100644 index 0000000..631ac30 --- /dev/null +++ b/Kernel/System/QueueService.pm @@ -0,0 +1,187 @@ +# -- +# Kernel/System/QueueService.pm - core module +# Managers Queue Services +# +# Copyright (C) (2014) (Carlos Rebelato, Rodrigo Gonçalves) (rodrigo.g@ufsc.br) +# -- +# $Id: writing-otrs-application.xml,v 1.1 2010/08/13 08:59:28 mg Exp $ +# -- +# This software comes with ABSOLUTELY NO WARRANTY. For details, see +# the enclosed file COPYING for license information (AGPL). If you +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. +# -- +# Author: Carlos Rebelato +# Date..: 19/02/2014 - Versão inicial +# Revision: 27/02/2014 - Module creation +# +package Kernel::System::QueueService; + +use strict; +use warnings; +use Data::Dumper; + +sub new { + my ( $Type, %Param ) = @_; + + # allocate new hash for object + my $Self = {%Param}; + bless( $Self, $Type ); + + return $Self; +} + +=item GetServiceList() + +Get list of services for a queue + + my %{service_id}{QueueName} = $QueueServiceObject->GetServiceList( + QueueID => 123, + ); + +=cut +sub GetServiceList { + my ( $Self, %Param ) = @_; + my %result = (); + + for (qw(QueueID)) { + if ( !$Param{$_} ) { + $Self->{LayoutObject}->FatalError( Message => Dumper( \%Param ) . "got no $_!" ); + } + } + + $Self->{DBObject}->Prepare( + SQL => " + select + a.service_id id, + b.name Name + from + queue_service a + inner join service b on(b.id = a.service_id) + where + a.queue_id = ?", + Bind => [ \$Param{QueueID} ] + ); + + while ( my @row = $Self->{DBObject}->FetchrowArray() ) { + $result{ $row[0] } = $row[1]; + } + + return %result; +} + +=item GetQueueList() + +Get list of queues for a service + + my %{queue_id}{QueueName} = $QueueServiceObject->GetQueueList( + ServiceID => 123, + ); + +=cut +sub GetQueueList { + my ( $Self, %Param ) = @_; + my %result = (); + + for (qw(ServiceID)) { + if ( !$Param{$_} ) { + $Self->{LayoutObject}->FatalError( Message => Dumper( \%Param ) . "got no $_!" ); + } + } + + $Self->{DBObject}->Prepare( + SQL => " + select + a.queue_id id, + b.name Name + from + queue_service a + inner join queue b on(b.id = a.queue_id) + where + a.service_id = ?", + Bind => [ \$Param{ServiceID} ] + ); + + while ( my @row = $Self->{DBObject}->FetchrowArray() ) { + $result{ $row[0] } = $row[1]; + } + + return %result; +} + + +=item SetQueueServices() + +Defines the list of services for a queue + + $QueueServiceObject->SetQueueServices( + QueueID => 123, + Services => @ServiceIDs + ); + +=cut +sub SetQueueServices { + my ( $Self, %Param ) = @_; + my %result = (); + + for (qw(QueueID Services)) { + if ( !$Param{$_} ) { + $Self->{LayoutObject}->FatalError( Message => Dumper( \%Param ) . "got no $_!" ); + } + } + + my $QueueID = $Param{"QueueID"}; + my @Services = @{$Param{"Services"}}; + + $Self->{DBObject}->Do( + SQL => "delete from queue_service where queue_id = ?", + Bind => [ \$Param{QueueID} ] + ); + + for my $service (@Services) { + $Self->{DBObject}->Do( + SQL => "insert into queue_service(queue_id,service_id) values (?,?)", + Bind => [\$Param{QueueID}, \$service] + ); + + } +} + +=item SetServiceQueues() + +Defines the list of services for a queue + + $QueueServiceObject->SetServiceQueues( + ServiceID => 123, + Queues => @ServiceIDs + ); + +=cut +sub SetServiceQueues { + my ( $Self, %Param ) = @_; + my %result = (); + + for (qw(ServiceID Queues)) { + if ( !$Param{$_} ) { + $Self->{LayoutObject}->FatalError( Message => Dumper( \%Param ) . "got no $_!" ); + } + } + + my $ServiceID = $Param{"ServiceID"}; + my @Queues = @{$Param{"Queues"}}; + + $Self->{DBObject}->Do( + SQL => "delete from queue_service where service_id = ?", + Bind => [ \$Param{ServiceID} ] + ); + + for my $queue (@Queues) { + $Self->{DBObject}->Do( + SQL => "insert into queue_service(queue_id,service_id) values (?,?)", + Bind => [\$queue, \$Param{ServiceID}] + ); + + } +} + + +1; diff --git a/QueueService.sopm b/QueueService.sopm new file mode 100755 index 0000000..c456f26 --- /dev/null +++ b/QueueService.sopm @@ -0,0 +1,40 @@ + + + QueueService + 1.0.0 + 3.x.x + SeTIC + http://www.setic.ufsc.br + Free + Associação de serviços a filas + + Versão 1.0.0 - Inicial + + + Módulo instalado com sucesso! + New Ticket Wizard + Queue services module installed successfully! + ? + ? + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file -- libgit2 0.21.2