diff --git a/GenerateOPM.sh b/GenerateOPM.sh
new file mode 100755
index 0000000..893a885
--- /dev/null
+++ b/GenerateOPM.sh
@@ -0,0 +1,4 @@
+#!/bin/bash
+LOCAL="$PWD"
+cd /opt/otrs
+bin/otrs.Console.pl Dev::Package::Build "$LOCAL"/InPersonTicket.sopm "$LOCAL"/
diff --git a/InPersonTicket.sopm b/InPersonTicket.sopm
new file mode 100755
index 0000000..d39d9c2
--- /dev/null
+++ b/InPersonTicket.sopm
@@ -0,0 +1,24 @@
+
+
+ InPersonTicket
+ 1.1.0
+ First version
+ Fixes for OTRS 5.0.x
+ 5.0.x
+ SeTIC-UFSC
+ setic.ufsc.br
+ Free
+ In person ticket
+ Module installed successfully.
+ ?
+ ?
+ Lib_setic
+
+
+
+
+
+
+
+
+
diff --git a/Kernel/Config/Files/InPersonTicket.xml b/Kernel/Config/Files/InPersonTicket.xml
new file mode 100644
index 0000000..e9e59b2
--- /dev/null
+++ b/Kernel/Config/Files/InPersonTicket.xml
@@ -0,0 +1,85 @@
+
+
+
+ Frontend module registration for the agent interface.
+ Ticket
+ Frontend::Agent::ModuleRegistration
+
+
+ Module for creating new ticket for in-person reception
+ Ticket
+ In person ticket
+
+ In person ticket
+ In person ticket
+ Action=InPersonTicket
+ Ticket
+
+ 8400
+
+
+
+
+
+
+
+ Default type ID for tickets
+ Ticket
+ Frontend::Agent::InPersonTicket
+
+ 6
+
+
+
+
+ Default customer ID for tickets
+ Ticket
+ Frontend::Agent::InPersonTicket
+
+ paginas@sistemas.ufsc.br
+
+
+
+
+ Default Owner ID for tickets
+ Ticket
+ Frontend::Agent::InPersonTicket
+
+ 1
+
+
+
+
+ Default domain for user e-mails.
+ Ticket
+ Frontend::Agent::InPersonTicket
+
+ ufsc.br,grad.ufsc.br,posgrad.ufsc.br
+
+
+
+
+ Model to use for reply to users.
+ Ticket
+ Frontend::Agent::InPersonTicket
+
+ 22
+
+
+
+
+ Model to use for reply to users when ticket is closed.
+ Ticket
+ Frontend::Agent::InPersonTicket
+
+ 5
+
+
+
+
\ No newline at end of file
diff --git a/Kernel/Language/pt_BR_InPersonTicket.pm b/Kernel/Language/pt_BR_InPersonTicket.pm
new file mode 100644
index 0000000..3d113ca
--- /dev/null
+++ b/Kernel/Language/pt_BR_InPersonTicket.pm
@@ -0,0 +1,26 @@
+# --
+# Kernel/Modules/pt_BR_StatisticsGraphs.pm - translations for StatisticsGraphs Module
+# Translations
+#
+# Copyright (C) 2015 (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_InPersonTicket;
+
+use strict;
+use warnings;
+use utf8;
+
+sub Data {
+ my $Self = shift;
+
+ $Self->{Translation}->{'Concluded'} = 'Concluído';
+ $Self->{Translation}->{'In person ticket'} = 'Atendimento presencial';
+ $Self->{Translation}->{'The ticket has been created with number:'} = 'Chamado criado com número: ';
+
+ return 1;
+}
+1;
\ No newline at end of file
diff --git a/Kernel/Modules/InPersonTicket.pm b/Kernel/Modules/InPersonTicket.pm
new file mode 100644
index 0000000..a45d4d0
--- /dev/null
+++ b/Kernel/Modules/InPersonTicket.pm
@@ -0,0 +1,320 @@
+# --
+# Kernel/Modules/OcurrenceControl.pm - frontend module
+# Copyright (C) (2013) (Carlos Rebelato) (carlos.rebelato@grad.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: Rodrigo Gonçalves
+# Data.: 18/05/2015 - Versão inicial
+#
+package Kernel::Modules::InPersonTicket;
+
+use strict;
+use warnings;
+use Data::Dumper;
+
+our @ObjectDependencies = (
+ "Kernel::Output::HTML::Layout",
+ "Kernel::System::Log",
+ "Kernel::System::Web::Request", # OLD ParamObject
+ "Kernel::System::DB",
+ "Kernel::Config",
+ "Kernel::System::CustomerUser",
+ "Kernel::System::Service",
+);
+
+sub new {
+ my ( $Type, %Param ) = @_;
+
+ # allocate new hash for object
+ my $Self = {%Param};
+ bless( $Self, $Type );
+
+ return $Self;
+}
+
+sub Run {
+ my ( $Self, %Param ) = @_;
+ my %Data = ();
+
+ my $layoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
+ my $paramObject = $Kernel::OM->Get("Kernel::System::Web::Request");
+ my $dbObject = $Kernel::OM->Get("Kernel::System::DB");
+ my $serviceObject = $Kernel::OM->Get("Kernel::System::Service");
+
+ $Self->BuildServiceBlock();
+
+ if ( $paramObject->GetParam( Param => "Subaction" ) && ($paramObject->GetParam( Param => "Subaction" ) eq "GetUserName") ) {
+ my $content = $Self->GetUserName(UserID => $paramObject->GetParam( Param => "UserID" ));
+
+ return $layoutObject->Attachment(
+ ContentType => 'application/text; charset=' . $layoutObject->{Charset},
+ Content => $content,
+ Type => 'inline',
+ NoCache => 1,
+ );
+ } elsif ( $paramObject->GetParam( Param => "Subaction" ) && ($paramObject->GetParam( Param => "Subaction" ) eq "Add") ) {
+ return $Self->CreateTicket();
+ }
+
+
+ my $Output = $layoutObject->Header( Title => "In person ticket" );
+ $Output .= $layoutObject->NavigationBar();
+ $Output .= $layoutObject->Output(
+ TemplateFile => 'InPersonTicket'
+ );
+
+ $Output .= $layoutObject->Footer();
+ return $Output;
+
+ return $Output;
+
+}
+
+sub GetUserName {
+ my ( $Self, %Param ) = @_;
+
+ my $userObject = $Kernel::OM->Get("Kernel::System::CustomerUser");
+ my %dados = $userObject->CustomerUserDataGet(User => $Param{"UserID"});
+
+ if (%dados) {
+ return $dados{UserFirstname};
+ } else {
+ return "";
+ }
+
+}
+
+sub BuildServiceBlock {
+ my ( $Self, %Param ) = @_;
+
+ my $layoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
+ my $paramObject = $Kernel::OM->Get("Kernel::System::Web::Request");
+ my $dbObject = $Kernel::OM->Get("Kernel::System::DB");
+ my $ocurrenceObject = $Kernel::OM->Get("Kernel::System::Ocurrence");
+ my $serviceObject = $Kernel::OM->Get("Kernel::System::Service");
+ my $serviceResponsibility = $Kernel::OM->Get("Kernel::System::ServiceResponsibility");
+
+ my $services = $serviceObject->ServiceListGet( Valid => 1, UserID => 1);
+ my @services = @$services;
+ @services = sort {$a->{Name} cmp $b->{Name}} @services;
+
+ foreach my $service (@services) {
+ $layoutObject->Block(
+ Name => 'selectService',
+ Data => {
+ ServiceID => $service->{ServiceID},
+ ServiceName => $Self->GetServiceName(Services => \@services, ServiceID => $service->{ServiceID}, ServiceName => $service->{Name}),
+ Disabled => $Self->LeafService(Services => \@services, ServiceID => $service->{ServiceID}) ? "" : "disabled"
+ }
+ );
+ }
+}
+
+sub GetServiceName {
+ my ( $Self, %Param ) = @_;
+
+ if ($Self->LeafService(%Param)) {
+ my @tokens = split("::", $Param{ServiceName});
+ return " " x (@tokens - 1) . @tokens[@tokens - 1];
+ } else {
+ return $Param{ServiceName};
+ }
+}
+
+sub LeafService {
+ my ( $Self, %Param ) = @_;
+
+ my $services = $Param{Services};
+ my @services = @$services;
+ my $serviceID = $Param{ServiceID};
+
+ foreach my $service (@services) {
+ if ((exists $service->{ParentID}) && ($service->{ParentID} == $serviceID)) {
+ return 0;
+ }
+ }
+
+ return 1;
+}
+
+sub GetQueueID() {
+ my ( $Self, %Param ) = @_;
+
+ my $ParamObject = $Kernel::OM->Get("Kernel::System::Web::Request");
+ my $QueueObject = $Kernel::OM->Get("Kernel::System::Queue");
+ my $ConfigObject = $Kernel::OM->Get("Kernel::Config");
+
+ # Gets default Queue
+ my $ConfigTicket = $ConfigObject->Get("Ticket::Frontend::CustomerTicketMessage");
+
+ my $QueueDefault = $ConfigTicket->{"QueueDefault"};
+
+ # Checks if there is a field for the queue
+ my %QueueListID = $QueueObject->QueueList( Valid => 1 );
+ my %QueueList = reverse $QueueObject->QueueList( Valid => 1 );
+ my $QueueID = $QueueList{$QueueDefault};
+ my $Queue = $QueueListID{$QueueID};
+
+ return ( $Queue, $QueueID );
+}
+
+sub CreateTicket {
+ my ( $Self, %Param ) = @_;
+ my %Data = ();
+
+ my $TicketObject = $Kernel::OM->Get("Kernel::System::Ticket");
+ my $ConfigObject = $Kernel::OM->Get("Kernel::Config");
+ my $ParamObject = $Kernel::OM->Get("Kernel::System::Web::Request");
+ my $BackendObject = $Kernel::OM->Get("Kernel::System::DynamicField::Backend");
+ my $DynamicFieldObject = $Kernel::OM->Get("Kernel::System::DynamicField");
+ my $CustomerUserObject = $Kernel::OM->Get("Kernel::System::CustomerUser");
+ my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
+
+ # Queue
+ my ( $Queue, $QueueID ) = $Self->GetQueueID(%Param);
+ $Data{QueueID} = $QueueID;
+ my $email = $ParamObject->GetParam( Param => "userID" );
+
+ $Self->{Config} = $ConfigObject->Get("Ticket::Frontend::CustomerTicketMessage");
+
+ $Self->{ConfigModule} = $ConfigObject->Get("Ticket::Frontend::InPersonTicket");
+
+ my $TicketID = $TicketObject->TicketCreate(
+ Title => "Atendimento presencial",
+ QueueID => $QueueID,
+ Priority => $Self->{Config}->{PriorityDefault},
+ Lock => 'unlock',
+ State => ($ParamObject->GetParam(Param => "concluded") ? 'closed successful' : 'new'),
+ ServiceID => $ParamObject->GetParam( Param => "ServiceID" ),
+ TypeID => $Self->{ConfigModule}->{TypeID},
+ CustomerID => $Self->GetUserIDFromEmail( EMail => $email, DefaultUserDomain => $Self->{ConfigModule}->{DefaultUserDomain}, DefaultCustomerID => $Self->{ConfigModule}->{DefaultCustomerID}),
+ CustomerUser => $Self->GetUserIDFromEmail( EMail => $email, DefaultUserDomain => $Self->{ConfigModule}->{DefaultUserDomain}, DefaultCustomerID => $Self->{ConfigModule}->{DefaultCustomerID}),
+ OwnerID => $Self->{ConfigModule}->{DefaultOwnerID},
+ UserID => $Self->{ConfigModule}->{DefaultOwnerID},
+ );
+
+ my $MimeType = 'text/plain';
+
+ # Create article
+ my $FullName = $ParamObject->GetParam( Param => "UserName" );
+
+ my $From = "\"$FullName\" <$email>";
+ my $ArticleID = $TicketObject->ArticleCreate(
+ TicketID => $TicketID,
+ ArticleType => 'phone',
+ SenderType => 'customer',
+ From => $email,
+ To => $Queue,
+ Subject => "Registro de atendimento",
+ Body => $ParamObject->GetParam( Param => "Description" ),
+ MimeType => $MimeType,
+ Charset => $LayoutObject->{UserCharset},
+ UserID => $Self->{ConfigModule}->{DefaultOwnerID},
+ HistoryType => $Self->{Config}->{HistoryType},
+ HistoryComment => $Self->{Config}->{HistoryComment} || '%%',
+ AutoResponseType => '',
+ OrigHeader => {
+ From => $From,
+ To => $Queue,
+ Subject => "Registro de atendimento",
+ Body => $ParamObject->GetParam( Param => "Description" ),
+ },
+ Queue => $Queue,
+ );
+
+ my $ReplyUser = $Kernel::OM->Get('Kernel::System::TemplateGenerator')->Template(
+ TemplateID => ($ParamObject->GetParam(Param => "concluded") ? $Self->{ConfigModule}->{ReplyModelIDClosed} : $Self->{ConfigModule}->{ReplyModelID}),
+ TicketID => $TicketID,
+ UserID => $Self->{ConfigModule}->{DefaultOwnerID},
+ );
+
+ my $corpo = $ParamObject->GetParam( Param => "Description" );
+ $ReplyUser =~ s/CONTEUDO/$corpo/g;
+
+ my %sysAddr = $Kernel::OM->Get('Kernel::System::SystemAddress')->SystemAddressGet(ID => 1);
+
+ my $FromSystem = $sysAddr{Name};
+
+ $MimeType = 'text/html';
+
+ $ArticleID = $TicketObject->ArticleSend(
+ TicketID => $TicketID,
+ ArticleType => 'note-internal', # email-external|email-internal|phone|fax|...
+ SenderType => 'agent', # agent|system|customer
+ From => $FromSystem,
+ To => $email, # not required but useful
+ Subject => 'Registro de atendimento', # required
+ Body => $ReplyUser, # required
+ Charset => $LayoutObject->{UserCharset},
+ MimeType => $MimeType,
+ Loop => 0, # 1|0 used for bulk emails
+ HistoryType => 'AddNote', # Move|AddNote|PriorityUpdate|WebRequestCustomer|...
+ HistoryComment => 'Auto-reply ao usuário',
+ NoAgentNotify => 0, # if you don't want to send agent notifications
+ UserID => $Self->{ConfigModule}->{DefaultOwnerID},
+ );
+
+ $Data{TicketNumber} = $TicketObject->TicketNumberLookup( TicketID => $TicketID );
+
+ # build output
+ my $Output = $LayoutObject->Header( Title => "In person ticket" );
+ my %BlockData = ();
+ $BlockData{TicketNumber} = '' . $Data{TicketNumber} . '';
+ $LayoutObject->Block(
+ Name => 'NewTicketCreated',
+ Data => \%BlockData
+ );
+
+ $Output .= $LayoutObject->NavigationBar();
+ $Output .= $LayoutObject->Output(
+ Data => \%Data,
+ TemplateFile => 'InPersonTicketCreated',
+ );
+ $Output .= $LayoutObject->Footer();
+ return $Output;
+}
+
+
+sub GetUserIDFromEmail {
+ my ( $Self, %Param ) = @_;
+
+ my $email = $Param{EMail};
+ my $result = $Param{DefaultCustomerID};
+ my $domainList = $Param{DefaultUserDomain};
+
+ if (index($email, '@') == -1) {
+ return $email;
+ }
+
+ my $CustomerUserObject = $Kernel::OM->Get("Kernel::System::CustomerUser");
+
+ if ($domainList) {
+ my @domains = split( ",", $domainList );
+
+ for my $domain (@domains) {
+ my @parts = split( "@", $email );
+ if ( $parts[1] eq $domain ) {
+ my $id = $parts[0];
+ my %List = $CustomerUserObject->CustomerSearch(
+ UserLogin => $id,
+ Valid => 1, # not required, default 1
+ );
+ if ( keys %List ) {
+ $result = $id;
+ return $result;
+ }
+ }
+ }
+ }
+
+ return $result;
+}
+
+
+
+1;
diff --git a/Kernel/Output/HTML/Templates/Standard/InPersonTicket.tt b/Kernel/Output/HTML/Templates/Standard/InPersonTicket.tt
new file mode 100644
index 0000000..f9fb057
--- /dev/null
+++ b/Kernel/Output/HTML/Templates/Standard/InPersonTicket.tt
@@ -0,0 +1,128 @@
+# --
+# Kernel/Output/HTML/Standard/EditOcurrence.tt - overview
+# Copyright (C) (2014) (Carlos Rebelatto) (carlos.rebelatto@grad.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.
+# --
+
+
+
[% Translate("In person ticket") | html %]
+
+
+
+
+
+
+
+
+
+[% WRAPPER JSOnDocumentComplete %]
+$("#SelectService").val([% Data.ServiceID %]);
+
+$("#userID").blur(function() {
+ dealEmail($("#userID").val());
+});
+
+[% END %]
+
diff --git a/Kernel/Output/HTML/Templates/Standard/InPersonTicketCreated.tt b/Kernel/Output/HTML/Templates/Standard/InPersonTicketCreated.tt
new file mode 100644
index 0000000..f4ddc2f
--- /dev/null
+++ b/Kernel/Output/HTML/Templates/Standard/InPersonTicketCreated.tt
@@ -0,0 +1,31 @@
+# --
+# Kernel/Output/HTML/Standard/EditOcurrence.tt - overview
+# Copyright (C) (2014) (Carlos Rebelatto) (carlos.rebelatto@grad.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.
+# --
+
+
+
[% Translate("In person ticket") | html %]
+
+
+
+
+
+
+ [% RenderBlockStart("NewTicketCreated") %]
+
+ [% RenderBlockEnd("NewTicketCreated") %]
+
+
+
+
+
--
libgit2 0.21.2