+
+
+
+
+
+
diff --git a/Kernel/Output/HTML/Standard/NewMaintenance.dtl b/Kernel/Output/HTML/Standard/NewMaintenance.dtl
new file mode 100644
index 0000000..66ec6a5
--- /dev/null
+++ b/Kernel/Output/HTML/Standard/NewMaintenance.dtl
@@ -0,0 +1,69 @@
+# --
+# Kernel/Output/HTML/Standard/NewMaintenance.dtl - template for quickly adding new maintenance
+# 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.
+# --
+
+
+
+
$Text{"New maintenance"}
+
+
+
+
+
$Text{"Enter maintenance data"}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Kernel/Output/HTML/Standard/NewMaintenanceCreated.dtl b/Kernel/Output/HTML/Standard/NewMaintenanceCreated.dtl
new file mode 100644
index 0000000..d70f886
--- /dev/null
+++ b/Kernel/Output/HTML/Standard/NewMaintenanceCreated.dtl
@@ -0,0 +1,34 @@
+# --
+# Kernel/Output/HTML/Standard/NewMaintenance.dtl - template for quickly adding new maintenance
+# 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.
+# --
+
+
+
+
+
+
+
diff --git a/Kernel/Output/HTML/Standard/NewQuickMaintenance.dtl b/Kernel/Output/HTML/Standard/NewQuickMaintenance.dtl
new file mode 100644
index 0000000..276f4fd
--- /dev/null
+++ b/Kernel/Output/HTML/Standard/NewQuickMaintenance.dtl
@@ -0,0 +1,50 @@
+# --
+# Kernel/Output/HTML/Standard/NewMaintenance.dtl - template for quickly adding new maintenance
+# 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.
+# --
+
+
+
+
$Text{"New maintenance"}
+
+
+
+
+
$Text{"Enter maintenance data"}
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/Kernel/System/DateUtils.pm b/Kernel/System/DateUtils.pm
new file mode 100644
index 0000000..fed088b
--- /dev/null
+++ b/Kernel/System/DateUtils.pm
@@ -0,0 +1,109 @@
+# --
+# Kernel/System/DateUtils.pm - date/time utils
+# Copyright (C) (2014) (Rodrigo Goncalves) (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 - First version
+#
+package Kernel::System::DateUtils;
+
+use strict;
+use warnings;
+use Data::Dumper;
+require DateTime;
+
+sub new {
+ my ( $Type, %Param ) = @_;
+
+ # allocate new hash for object
+ my $Self = {%Param};
+ bless( $Self, $Type );
+
+ # creates required objects
+
+ return $Self;
+}
+
+=item NewTimestamp()
+
+Creates a new date from the parameters
+
+ $ocurrenceObject->NewTimestamp(
+ Year => int,
+ Month => int,
+ Day => int,
+ Hour => int,
+ Minute => int,
+ Second => int
+ );
+
+=cut
+sub NewTimestamp {
+ my ( $Self, %Param ) = @_;
+
+ my $date = DateTime->new(
+ year => $Param{Year},
+ month => $Param{Month},
+ day => $Param{Day},
+ hour => $Param{Hour},
+ minute => $Param{Minute},
+ second => $Param{Second}
+ );
+
+ return $date;
+}
+=item AddDays()
+
+Adds a number of days to a timestamp
+
+ $ocurrenceObject->AddDays(
+ Timestamp => DateTime,
+ Days => int
+ );
+
+=cut
+sub AddDays {
+ my ( $Self, %Param ) = @_;
+ my $timestamp = $Param{Timestamp};
+ $timestamp->add( days => $Param{Days} );
+}
+
+=item GetDateFromParams()
+
+Create a DateTime based on parameter values
+
+ $ocurrenceObject->GetDateFromParams(
+ Prefix => string,
+ ParamObject => ParamObject
+ );
+
+=cut
+sub GetDateFromParams {
+ my ( $Self, %Param ) = @_;
+ my $Prefix = $Param{"Prefix"};
+ my $ParamObject = $Param{"ParamObject"};
+
+ return $Self->NewTimestamp(
+ Year => $ParamObject->GetParam(Param => $Prefix . "Year"),
+ Month => $ParamObject->GetParam(Param => $Prefix . "Month"),
+ Day => $ParamObject->GetParam(Param => $Prefix . "Day"),
+ Hour => $ParamObject->GetParam(Param => $Prefix . "Hour"),
+ Minute => $ParamObject->GetParam(Param => $Prefix . "Minute"),
+ Second => 0
+ );
+
+}
+
+sub SQLDate {
+ my ( $Self, %Param ) = @_;
+ my $timestamp = $Param{"Timestamp"};
+ return $timestamp->strftime("%y-%m-%d %H:%M:%S");
+}
+
+1;
diff --git a/Kernel/System/Maintenance.pm b/Kernel/System/Maintenance.pm
new file mode 100644
index 0000000..7363296
--- /dev/null
+++ b/Kernel/System/Maintenance.pm
@@ -0,0 +1,109 @@
+# --
+# Kernel/System/Maintenanca.pm - maintenance instance
+# Copyright (C) (2014) (Rodrigo Goncalves) (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 - First version
+#
+package Kernel::System::Maintenance;
+
+use strict;
+use warnings;
+use Data::Dumper;
+
+sub new {
+ my ( $Type, %Param ) = @_;
+
+ # allocate new hash for object
+ my $Self = {%Param};
+ bless( $Self, $Type );
+
+ # creates required objects
+
+ return $Self;
+}
+
+=item CreateMaintenance()
+
+Creates a maintenance
+
+ $ocurrenceObject->CreateMaintenance(
+ Description => string
+ StartDate => string (format yyyy-mm-dd hh:nn:ss)
+ ScheduledEndDate => string (format yyyy-mm-dd hh:nn:ss)
+ UserID => integer
+ );
+
+=cut
+
+sub CreateMaintenance {
+ my ( $Self, %Param ) = @_;
+
+ for (qw(Description StartDate ScheduledEndDate UserID)) {
+ if ( !$Param{$_} ) {
+ $Self->{LayoutObject}->FatalError( Message => Dumper( \%Param ) . "got no $_!" );
+ }
+ }
+
+ $Self->{DBObject}->Do(
+ SQL => "insert into maintenance (description, start_date, scheduled_end_date, user_id) values (?, ?, ?, ?)",
+ Bind => [ \$Param{Description}, \$Param{StartDate}, \$Param{ScheduledEndDate}, \$Param{UserID} ]
+ );
+}
+
+sub ListCurrentMaintenances {
+ my ( $Self, %Param ) = @_;
+ my @retorno = ();
+
+ $Self->{DBObject}->Prepare(
+ SQL =>
+"SELECT id,description,start_date FROM maintenance where start_date < CURRENT_TIMESTAMP and end_date = 0 ORDER BY start_date DESC",
+ Bind => []
+ );
+
+ while ( my @row = $Self->{DBObject}->FetchrowArray() ) {
+ my %ret = ();
+ $ret{'Description'} = $row[1];
+ $ret{'StartDate'} = $row[2];
+ $ret{'ID'} = $row[0];
+ push @retorno, \%ret;
+ }
+
+ return @retorno;
+}
+
+sub EndMaintenance {
+ my ( $Self, %Param ) = @_;
+
+ $Self->{DBObject}->Prepare(
+ SQL => "UPDATE maintenance SET end_date=CURRENT_TIMESTAMP WHERE id=?",
+ Bind => [ \$Param{ID} ]
+ );
+
+}
+
+sub GetStatusID {
+ my ( $Self, %Param ) = @_;
+ my %retorno = ();
+
+ $Self->{DBObject}->Prepare(
+ SQL => "SELECT count(id), max(id) FROM maintenance where start_date < CURRENT_TIMESTAMP and end_date = 0",
+ Bind => []
+ );
+
+ my @row = $Self->{DBObject}->FetchrowArray();
+ if ($row[0] != 0) {
+ return ( $row[0], $row[1] );
+ }
+ else {
+ return ( 0, 0 );
+ }
+}
+
+1;
diff --git a/OTRSMaintenanceManager.sopm b/OTRSMaintenanceManager.sopm
new file mode 100755
index 0000000..2d4a717
--- /dev/null
+++ b/OTRSMaintenanceManager.sopm
@@ -0,0 +1,72 @@
+
+
+ NewTicketWizard
+ 1.1.4
+ 3.x.x
+ SeTIC
+ http://www.setic.ufsc.br
+ Free
+ Assistente de chamados
+
+ Versão 1.0.0 - Inicial
+ Versão 1.0.1 - Ajusta listagem de servicos do Service forms, correcao no formulario de edicao de servico
+ Versão 1.0.2 - Ajuste na hierarquia de servicos
+ Versão 1.0.9 - Primeira versao para producao
+ Versão 1.1.1 - Suporte para abertura pública de tickets.
+ Versão 1.1.2 - Suporte para múltiplos domínios.
+ Versão 1.1.3 - Link para abrir segundo chamado na tela de finalização da abertura
+ Versão 1.1.4 - Aumento na fonte do botao de enviar
+
+ Módulo instalado com sucesso!
+ New Ticket Wizard
+ New Ticket Wizard module installed successfully!
+ ?
+ ?
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/script.sql b/script.sql
new file mode 100644
index 0000000..565c04c
--- /dev/null
+++ b/script.sql
@@ -0,0 +1 @@
+create table maintenance(id integer not null primary key auto_increment, user_id integer, description text not null, start_date timestamp not null, scheduled_end_date timestamp, end_date timestamp, comments text);
diff --git a/script.sql~ b/script.sql~
new file mode 100644
index 0000000..587ca23
--- /dev/null
+++ b/script.sql~
@@ -0,0 +1 @@
+create table maintenance(id integer not null primary key auto_increment, description text not null, start_date timestamp not null, scheduled_end_date timestamp, end_date timestamp, comments text);
diff --git a/var/httpd/htdocs/js/maintenance.js b/var/httpd/htdocs/js/maintenance.js
new file mode 100644
index 0000000..584ee4a
--- /dev/null
+++ b/var/httpd/htdocs/js/maintenance.js
@@ -0,0 +1,51 @@
+/**
+ * Javascript to indicate maintenances
+ */
+
+var maintenanceManagerLastID = "";
+var maintenanceManagerTotalMaintenance = "";
+
+$(document).ready(function() {
+ if ($("#maintenanceList").length) {
+ if ($("#maintenanceList").html() == "") {
+ $("#maintenanceList").parent().hide();
+ }
+ updateStatusMaintenance();
+ }
+});
+
+function updateStatusMaintenance() {
+ setTimeout(function updateStatus() {
+ $.getJSON("/otrs/index.pl?Action=MaintenanceManager;Subaction=StatusID",
+ function parseJSON(data) {
+ var _maintenanceManagerTotalMaintenance = data[0];
+ var _maintenanceManagerLastID = data[1];
+ console.log("lastMaintenance=" + _maintenanceManagerLastID + " , totalMaintenance=" + _maintenanceManagerTotalMaintenance);
+
+ if ((_maintenanceManagerLastID != maintenanceManagerLastID)
+ || (_maintenanceManagerTotalMaintenance != maintenanceManagerTotalMaintenance)) {
+ maintenanceManagerTotalMaintenance = _maintenanceManagerTotalMaintenance;
+ maintenanceManagerLastID = _maintenanceManagerLastID;
+
+ if (_maintenanceManagerTotalMaintenance == 0) {
+ $("#maintenanceList").html("");
+ $("#maintenanceList").parent().hide();
+ updateStatusMaintenance();
+ } else {
+ $("#maintenanceList").parent().show();
+ updateContent();
+ }
+ }
+ });
+ }, 10000);
+}
+
+
+
+function updateContent() {
+ $.get("/otrs/index.pl?Action=MaintenanceManager;Subaction=Status",
+ function(data) {
+ $("#maintenanceList").html(data);
+ updateStatusMaintenance();
+ });
+}
\ No newline at end of file
--
libgit2 0.21.2