Commit d55c14fd9e7a6fb5f37fef14f3636de1fd07712d
0 parents
Exists in
master
first commit
Showing
20 changed files
with
1131 additions
and
0 deletions
Show diff stats
| 1 | +++ a/.project | |
| ... | ... | @@ -0,0 +1,18 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8"?> | |
| 2 | +<projectDescription> | |
| 3 | + <name>otrs-maintenance-manager</name> | |
| 4 | + <comment></comment> | |
| 5 | + <projects> | |
| 6 | + <project>otrs</project> | |
| 7 | + </projects> | |
| 8 | + <buildSpec> | |
| 9 | + <buildCommand> | |
| 10 | + <name>org.epic.perleditor.perlbuilder</name> | |
| 11 | + <arguments> | |
| 12 | + </arguments> | |
| 13 | + </buildCommand> | |
| 14 | + </buildSpec> | |
| 15 | + <natures> | |
| 16 | + <nature>org.epic.perleditor.perlnature</nature> | |
| 17 | + </natures> | |
| 18 | +</projectDescription> | ... | ... |
No preview for this file type
No preview for this file type
| 1 | +++ a/Kernel/Config/Files/MaintenanceManager.xml | |
| ... | ... | @@ -0,0 +1,138 @@ |
| 1 | +<?xml version="1.0" encoding="UTF-8" ?> | |
| 2 | +<otrs_config init="Application" | |
| 3 | + version="1.0"> | |
| 4 | + | |
| 5 | + <ConfigItem Name="Frontend::Module###MaintenanceManager" Required="0" Valid="1"> | |
| 6 | + <Description Translatable="1">FrontendModuleRegistration for MaintenanceManager module.</Description> | |
| 7 | + <Group>ITSM</Group> | |
| 8 | + <SubGroup>MaintenanceManager</SubGroup> | |
| 9 | + <Setting> | |
| 10 | + <FrontendModuleReg> | |
| 11 | + <Description>Module for managing maintenances</Description> | |
| 12 | + <NavBarName>MaintenanceManager</NavBarName> | |
| 13 | + <NavBar> | |
| 14 | + <Description Translatable="1">Maintenances</Description> | |
| 15 | + <Name Translatable="1">Maintenances</Name> | |
| 16 | + <Link> | |
| 17 | + </Link> | |
| 18 | + <NavBar>MaintenanceManager</NavBar> | |
| 19 | + <Type>Menu</Type> | |
| 20 | + <Prio>8400</Prio> | |
| 21 | + </NavBar> | |
| 22 | + <!-- JS/CSS --> | |
| 23 | + <Loader> | |
| 24 | + <!-- | |
| 25 | + <JavaScript></JavaScript> | |
| 26 | + <CSS></CSS> | |
| 27 | + --> | |
| 28 | + </Loader> | |
| 29 | + </FrontendModuleReg> | |
| 30 | + </Setting> | |
| 31 | + </ConfigItem> | |
| 32 | + | |
| 33 | + <ConfigItem Name="Frontend::Module###MaintenanceManagerManager" Required="0" Valid="1"> | |
| 34 | + <Description Translatable="1">FrontendModuleRegistration for MaintenanceManager module.</Description> | |
| 35 | + <Setting> | |
| 36 | + <FrontendModuleReg> | |
| 37 | + <Description>Module for managing maintenances</Description> | |
| 38 | + <NavBarName>MaintenanceManager</NavBarName> | |
| 39 | + <NavBar> | |
| 40 | + <Description Translatable="1">Maintenances</Description> | |
| 41 | + <Name Translatable="1">Maintenances</Name> | |
| 42 | + <Link>Action=MaintenanceManager</Link> | |
| 43 | + <NavBar>MaintenanceManager</NavBar> | |
| 44 | + <Type> | |
| 45 | + </Type> | |
| 46 | + <Prio>880</Prio> | |
| 47 | + </NavBar> | |
| 48 | + <!-- JS/CSS --> | |
| 49 | + <Loader> | |
| 50 | + <!-- | |
| 51 | + <JavaScript></JavaScript> | |
| 52 | + <CSS></CSS> | |
| 53 | + --> | |
| 54 | + </Loader> | |
| 55 | + </FrontendModuleReg> | |
| 56 | + </Setting> | |
| 57 | + </ConfigItem> | |
| 58 | + | |
| 59 | + <ConfigItem Name="Frontend::Module###NewMaintenance" Required="1" Valid="1"> | |
| 60 | + <Description Translatable="1">New maintenance</Description> | |
| 61 | + <!-- usado na configuracao interna (hierarquia) --> | |
| 62 | + <Group>ITSM</Group> | |
| 63 | + <SubGroup>MaintenanceManager</SubGroup> | |
| 64 | + <!-- usado na configuracao interna (hierarquia) --> | |
| 65 | + <Setting> | |
| 66 | + <FrontendModuleReg> | |
| 67 | + <Title Translatable="1">New maintenance</Title> | |
| 68 | + <Group>admin</Group> | |
| 69 | + <Description> | |
| 70 | + </Description> | |
| 71 | + <NavBar> | |
| 72 | + <Description>New maintenance</Description> | |
| 73 | + <Name>New maintenance</Name> | |
| 74 | + <Image>overview.png</Image> | |
| 75 | + <Link>Action=NewMaintenance</Link> | |
| 76 | + <NavBar>MaintenanceManager</NavBar> | |
| 77 | + <Type> | |
| 78 | + </Type> | |
| 79 | + <Prio>920</Prio> | |
| 80 | + <Block> | |
| 81 | + </Block> | |
| 82 | + </NavBar> | |
| 83 | + </FrontendModuleReg> | |
| 84 | + </Setting> | |
| 85 | + </ConfigItem> | |
| 86 | + | |
| 87 | + <ConfigItem Name="Frontend::Module###NewQuickMaintenance" Required="1" Valid="1"> | |
| 88 | + <Description Translatable="1">New quick maintenance</Description> | |
| 89 | + <!-- usado na configuracao interna (hierarquia) --> | |
| 90 | + <Group>ITSM</Group> | |
| 91 | + <SubGroup>MaintenanceManager</SubGroup> | |
| 92 | + <!-- usado na configuracao interna (hierarquia) --> | |
| 93 | + <Setting> | |
| 94 | + <FrontendModuleReg> | |
| 95 | + <Title Translatable="1">New quick maintenance</Title> | |
| 96 | + <Group>admin</Group> | |
| 97 | + <Description> | |
| 98 | + </Description> | |
| 99 | + <NavBar> | |
| 100 | + <Description>New quick maintenance</Description> | |
| 101 | + <Name>New quick maintenance</Name> | |
| 102 | + <Image>overview.png</Image> | |
| 103 | + <Link>Action=NewQuickMaintenance</Link> | |
| 104 | + <NavBar>MaintenanceManager</NavBar> | |
| 105 | + <Type> | |
| 106 | + </Type> | |
| 107 | + <Prio>900</Prio> | |
| 108 | + <Block> | |
| 109 | + </Block> | |
| 110 | + </NavBar> | |
| 111 | + </FrontendModuleReg> | |
| 112 | + </Setting> | |
| 113 | + </ConfigItem> | |
| 114 | + | |
| 115 | + <ConfigItem Name="Frontend::NotifyModule###999-MaintenanceAdvisor" Required="1" Valid="1"> | |
| 116 | + <Description Translatable="1">Defines the module to display maintenances in progress.</Description> | |
| 117 | + <Group>Framework</Group> | |
| 118 | + <SubGroup>Frontend::Agent::ModuleNotify</SubGroup> | |
| 119 | + <Setting> | |
| 120 | + <Hash> | |
| 121 | + <Item Key="Module">Kernel::Output::HTML::MaintenanceAdvisor</Item> | |
| 122 | + </Hash> | |
| 123 | + </Setting> | |
| 124 | + </ConfigItem> | |
| 125 | + | |
| 126 | + <ConfigItem Name="Loader::Agent::CommonJS###999-MaintenanceAdvisor" Required="0" Valid="1"> | |
| 127 | + <Description Translatable="1">Maintenance Advisor Warning.</Description> | |
| 128 | + <Group>Framework</Group> | |
| 129 | + <SubGroup>Core::Web</SubGroup> | |
| 130 | + <Setting> | |
| 131 | + <Array> | |
| 132 | + <Item>maintenance.js</Item> | |
| 133 | + </Array> | |
| 134 | + </Setting> | |
| 135 | + </ConfigItem> | |
| 136 | + | |
| 137 | + | |
| 138 | +</otrs_config> | |
| 0 | 139 | \ No newline at end of file | ... | ... |
| 1 | +++ a/Kernel/Language/pt_BR_MaintenanceManager.pm | |
| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | +# -- | |
| 2 | +# Kernel/Modules/pt_BR_MaintenanceManager.pm - frontend module for managing maintenances | |
| 3 | +# Translations | |
| 4 | +# | |
| 5 | +# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br) | |
| 6 | +# -- | |
| 7 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
| 8 | +# the enclosed file COPYING for license information (AGPL). If you | |
| 9 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
| 10 | +# -- | |
| 11 | +package Kernel::Language::pt_BR_MaintenanceManager; | |
| 12 | + | |
| 13 | +use strict; | |
| 14 | +use warnings; | |
| 15 | + | |
| 16 | +sub Data { | |
| 17 | + my $Self = shift; | |
| 18 | + $Self->{Translation}->{'Maintenances'} = 'Manutenções'; | |
| 19 | + $Self->{Translation}->{'New maintenance'} = 'Nova manutenção'; | |
| 20 | + $Self->{Translation}->{'Enter maintenance data'} = 'Informe os dados da manutenção'; | |
| 21 | + $Self->{Translation}->{'Start date'} = 'Início'; | |
| 22 | + $Self->{Translation}->{'Scheduled end date'} = 'Data prevista de término'; | |
| 23 | + $Self->{Translation}->{'Description'} = 'Descrição'; | |
| 24 | + $Self->{Translation}->{'Comments'} = 'Comentário'; | |
| 25 | + return 1; | |
| 26 | +} | |
| 27 | +1; | |
| 0 | 28 | \ No newline at end of file | ... | ... |
| 1 | +++ a/Kernel/Modules/MaintenanceManager.pm | |
| ... | ... | @@ -0,0 +1,102 @@ |
| 1 | +# -- | |
| 2 | +# Kernel/Modules/MaintenanceManager.pm - frontend module for manager maintenances | |
| 3 | +# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br) | |
| 4 | +# -- | |
| 5 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
| 6 | +# the enclosed file COPYING for license information (AGPL). If you | |
| 7 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
| 8 | +# -- | |
| 9 | +package Kernel::Modules::MaintenanceManager; | |
| 10 | + | |
| 11 | +use strict; | |
| 12 | +use warnings; | |
| 13 | + | |
| 14 | +use Kernel::System::CustomerUser; | |
| 15 | +use Kernel::System::State; | |
| 16 | +use Kernel::System::SystemAddress; | |
| 17 | +use Kernel::System::Queue; | |
| 18 | +use Kernel::System::Web::UploadCache; | |
| 19 | +use Kernel::System::DynamicField; | |
| 20 | +use Kernel::System::DynamicField::Backend; | |
| 21 | +use Kernel::System::VariableCheck qw(:all); | |
| 22 | +use Data::Dumper; | |
| 23 | +require Kernel::Output::HTML::MaintenanceAdvisor; | |
| 24 | +require Kernel::System::Maintenance; | |
| 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 | + # check needed objects | |
| 34 | + for ( | |
| 35 | + qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject) | |
| 36 | + ) | |
| 37 | + { | |
| 38 | + if ( !$Self->{$_} ) { | |
| 39 | + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); | |
| 40 | + } | |
| 41 | + } | |
| 42 | + | |
| 43 | + # needed objects | |
| 44 | + $Self->{CustomerUserObject} = Kernel::System::CustomerUser->new(%Param); | |
| 45 | + $Self->{StateObject} = Kernel::System::State->new(%Param); | |
| 46 | + $Self->{SystemAddress} = Kernel::System::SystemAddress->new(%Param); | |
| 47 | + $Self->{UploadCacheObject} = Kernel::System::Web::UploadCache->new(%Param); | |
| 48 | + $Self->{DynamicFieldObject} = Kernel::System::DynamicField->new(%Param); | |
| 49 | + $Self->{BackendObject} = Kernel::System::DynamicField::Backend->new(%Param); | |
| 50 | + $Self->{ServiceObject} = Kernel::System::Service->new(%Param); | |
| 51 | + $Self->{MaintenanceObject} = Kernel::System::Maintenance->new(%Param); | |
| 52 | + $Self->{MaintenanceAdvisor} = Kernel::Output::HTML::MaintenanceAdvisor->new(%Param); | |
| 53 | + | |
| 54 | + return $Self; | |
| 55 | +} | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | +sub Run { | |
| 60 | + my ( $Self, %Param ) = @_; | |
| 61 | + my %Data = (); | |
| 62 | + my $Subaction = $Self->{ParamObject}->GetParam( Param => "Subaction" ); | |
| 63 | + | |
| 64 | + if ($Subaction eq "EndMaintenance") { | |
| 65 | + $Self->{MaintenanceObject}->EndMaintenance(ID => $Self->{ParamObject}->GetParam( Param => "ID" )); | |
| 66 | + } elsif ($Subaction eq "Status") { | |
| 67 | + return $Self->{LayoutObject}->Attachment( | |
| 68 | + ContentType => 'text; charset=' . $Self->{LayoutObject}->{Charset}, | |
| 69 | + Content => $Self->{MaintenanceAdvisor}->GetStatus(), | |
| 70 | + Type => 'inline', | |
| 71 | + NoCache => 1, | |
| 72 | + ); | |
| 73 | + } elsif ($Subaction eq "StatusID") { | |
| 74 | + my ($totalMaintenances, $lastMaintenance) = $Self->{MaintenanceObject}->GetStatusID(); | |
| 75 | + return $Self->{LayoutObject}->Attachment( | |
| 76 | + ContentType => 'application/json; charset=' . $Self->{LayoutObject}->{Charset}, | |
| 77 | + Content => "[$totalMaintenances, $lastMaintenance]", | |
| 78 | + Type => 'inline', | |
| 79 | + NoCache => 1, | |
| 80 | + ); | |
| 81 | + } | |
| 82 | + | |
| 83 | + # build output | |
| 84 | + my @maintenances = $Self->{MaintenanceObject}->ListCurrentMaintenances(); | |
| 85 | + for my $maintenance ( @maintenances ) { | |
| 86 | + $Self->{LayoutObject}->Block( | |
| 87 | + Name => 'Maintenance', | |
| 88 | + Data => $maintenance, | |
| 89 | + ); | |
| 90 | + } | |
| 91 | + | |
| 92 | + my $Output = $Self->{LayoutObject}->Header( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Maintenances") ); | |
| 93 | + $Output .= $Self->{LayoutObject}->NavigationBar(); | |
| 94 | + $Output .= $Self->{LayoutObject}->Output( | |
| 95 | + Data => \%Data, | |
| 96 | + TemplateFile => 'Maintenances', | |
| 97 | + ); | |
| 98 | + $Output .= $Self->{LayoutObject}->Footer(); | |
| 99 | + return $Output; | |
| 100 | +} | |
| 101 | + | |
| 102 | +1; | ... | ... |
| 1 | +++ a/Kernel/Modules/NewMaintenance.pm | |
| ... | ... | @@ -0,0 +1,134 @@ |
| 1 | +# -- | |
| 2 | +# Kernel/Modules/NewMaintenance.pm - frontend module for quick adding new maintenances | |
| 3 | +# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br) | |
| 4 | +# -- | |
| 5 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
| 6 | +# the enclosed file COPYING for license information (AGPL). If you | |
| 7 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
| 8 | +# -- | |
| 9 | +package Kernel::Modules::NewMaintenance; | |
| 10 | + | |
| 11 | +use strict; | |
| 12 | +use warnings; | |
| 13 | + | |
| 14 | +use Kernel::System::CustomerUser; | |
| 15 | +use Kernel::System::State; | |
| 16 | +use Kernel::System::SystemAddress; | |
| 17 | +use Kernel::System::Queue; | |
| 18 | +use Kernel::System::Web::UploadCache; | |
| 19 | +use Kernel::System::DynamicField; | |
| 20 | +use Kernel::System::DynamicField::Backend; | |
| 21 | +use Kernel::System::VariableCheck qw(:all); | |
| 22 | +use Data::Dumper; | |
| 23 | +require Kernel::System::ITSMChange; | |
| 24 | + | |
| 25 | +sub new { | |
| 26 | + my ( $Type, %Param ) = @_; | |
| 27 | + | |
| 28 | + # allocate new hash for object | |
| 29 | + my $Self = {%Param}; | |
| 30 | + bless( $Self, $Type ); | |
| 31 | + | |
| 32 | + # check needed objects | |
| 33 | + for ( | |
| 34 | + qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject) | |
| 35 | + ) | |
| 36 | + { | |
| 37 | + if ( !$Self->{$_} ) { | |
| 38 | + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); | |
| 39 | + } | |
| 40 | + } | |
| 41 | + | |
| 42 | + # needed objects | |
| 43 | + $Self->{CustomerUserObject} = Kernel::System::CustomerUser->new(%Param); | |
| 44 | + $Self->{StateObject} = Kernel::System::State->new(%Param); | |
| 45 | + $Self->{SystemAddress} = Kernel::System::SystemAddress->new(%Param); | |
| 46 | + $Self->{UploadCacheObject} = Kernel::System::Web::UploadCache->new(%Param); | |
| 47 | + $Self->{DynamicFieldObject} = Kernel::System::DynamicField->new(%Param); | |
| 48 | + $Self->{BackendObject} = Kernel::System::DynamicField::Backend->new(%Param); | |
| 49 | + $Self->{ServiceObject} = Kernel::System::Service->new(%Param); | |
| 50 | + $Self->{ChangeObject} = Kernel::System::ITSMChange->new(%Param); | |
| 51 | + | |
| 52 | + return $Self; | |
| 53 | +} | |
| 54 | + | |
| 55 | +sub Run { | |
| 56 | + my ( $Self, %Param ) = @_; | |
| 57 | + my %Data = (); | |
| 58 | + my $SubAction = $Self->{ParamObject}->GetParam( Param => "Subaction" ); | |
| 59 | + my $Template = 'NewMaintenance'; | |
| 60 | + | |
| 61 | + # common stuff | |
| 62 | + if ( $Self->{LayoutObject}->{BrowserRichText} ) { | |
| 63 | + $Self->{LayoutObject}->Block( | |
| 64 | + Name => 'RichText', | |
| 65 | + Data => \%Param, | |
| 66 | + ); | |
| 67 | + } | |
| 68 | + | |
| 69 | + # Date/time chooses | |
| 70 | + my $StartDateSelectionString = $Self->{LayoutObject}->BuildDateSelection( | |
| 71 | + Format => 'DateInputFormatLong', | |
| 72 | + Prefix => 'StartDate', | |
| 73 | + RequestedTimeOptional => 1, | |
| 74 | + Validate => 1, | |
| 75 | + ); | |
| 76 | + my $ScheduledEndDateSelectionString = $Self->{LayoutObject}->BuildDateSelection( | |
| 77 | + Format => 'DateInputFormatLong', | |
| 78 | + Prefix => 'ScheduledEndDate', | |
| 79 | + RequestedTimeOptional => 1, | |
| 80 | + Validate => 1, | |
| 81 | + ); | |
| 82 | + | |
| 83 | + $Data{StartDateSelectionString} = $StartDateSelectionString; | |
| 84 | + $Data{ScheduledEndDateSelectionString} = $ScheduledEndDateSelectionString; | |
| 85 | + | |
| 86 | + if ( $SubAction eq "CreateMaintenance" ) { | |
| 87 | + $Template = "NewMaintenanceCreated"; | |
| 88 | + $Self->Debug( "Params = " . Dumper( $Self->{ParamObject}->GetParamNames() ) ); | |
| 89 | + $Data{StartDate} = $Self->GetDateTime( Prefix => "StartDate" ); | |
| 90 | + $Data{ScheduledEndDate} = $Self->GetDateTime( Prefix => "ScheduledEndDate" ); | |
| 91 | + $Data{Description} = $Self->{ParamObject}->GetParam( Param => "Description" ); | |
| 92 | + | |
| 93 | + my $ChangeID = $Self->{ChangeObject}->ChangeAdd( | |
| 94 | + ChangeTitle => 'Manutenção de serviço', # (optional) | |
| 95 | + Description => $Data{Description}, # (optional) | |
| 96 | + ChangeStateID => 114, # (optional) | |
| 97 | + CategoryID => 1, # (optional) or CategoryID => 4 | |
| 98 | + ImpactID => 1, # (optional) or ImpactID => 5 | |
| 99 | + PriorityID => 1, # (optional) or PriorityID => 6 | |
| 100 | + RequestedTime => $Data{StartDate}, # (optional) | |
| 101 | + UserID => 1, | |
| 102 | + ); | |
| 103 | + } | |
| 104 | + else { | |
| 105 | + | |
| 106 | + } | |
| 107 | + | |
| 108 | + # build output | |
| 109 | + my $Output = $Self->{LayoutObject}->Header( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Maintenances") ); | |
| 110 | + $Output .= $Self->{LayoutObject}->NavigationBar(); | |
| 111 | + $Output .= $Self->{LayoutObject}->Output( Data => \%Data, TemplateFile => $Template ); | |
| 112 | + $Output .= $Self->{LayoutObject}->Footer(); | |
| 113 | + return $Output; | |
| 114 | +} | |
| 115 | + | |
| 116 | +sub Debug { | |
| 117 | + my $Self = shift; | |
| 118 | + print STDERR @_; | |
| 119 | +} | |
| 120 | + | |
| 121 | +sub GetDateTime { | |
| 122 | + my ( $Self, %Param ) = @_; | |
| 123 | + my $Prefix = $Param{"Prefix"}; | |
| 124 | + | |
| 125 | + my $Date = sprintf '%04d-%02d-%02d %02d:%02d:00', $Self->{ParamObject}->GetParam( Param => $Prefix . "Year" ), | |
| 126 | + $Self->{ParamObject}->GetParam( Param => $Prefix . "Month" ), | |
| 127 | + $Self->{ParamObject}->GetParam( Param => $Prefix . "Day" ), | |
| 128 | + $Self->{ParamObject}->GetParam( Param => $Prefix . "Hour" ), | |
| 129 | + $Self->{ParamObject}->GetParam( Param => $Prefix . "Minute"); | |
| 130 | + | |
| 131 | + return $Date; | |
| 132 | +} | |
| 133 | + | |
| 134 | +1; | ... | ... |
| 1 | +++ a/Kernel/Modules/NewQuickMaintenance.pm | |
| ... | ... | @@ -0,0 +1,105 @@ |
| 1 | +# -- | |
| 2 | +# Kernel/Modules/NewQuickMaintenance.pm - frontend module for quick adding new maintenances | |
| 3 | +# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br) | |
| 4 | +# -- | |
| 5 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
| 6 | +# the enclosed file COPYING for license information (AGPL). If you | |
| 7 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
| 8 | +# -- | |
| 9 | +package Kernel::Modules::NewQuickMaintenance; | |
| 10 | + | |
| 11 | +use strict; | |
| 12 | +use warnings; | |
| 13 | + | |
| 14 | +require Kernel::System::Maintenance; | |
| 15 | +require DateTime; | |
| 16 | +require Data::Dumper; | |
| 17 | +require Kernel::System::DateUtils; | |
| 18 | +use Kernel::System::VariableCheck qw(:all); | |
| 19 | + | |
| 20 | +sub new { | |
| 21 | + my ( $Type, %Param ) = @_; | |
| 22 | + | |
| 23 | + # allocate new hash for object | |
| 24 | + my $Self = {%Param}; | |
| 25 | + bless( $Self, $Type ); | |
| 26 | + | |
| 27 | + # check needed objects | |
| 28 | + for ( | |
| 29 | + qw(ParamObject DBObject TicketObject LayoutObject LogObject QueueObject ConfigObject) | |
| 30 | + ) | |
| 31 | + { | |
| 32 | + if ( !$Self->{$_} ) { | |
| 33 | + $Self->{LayoutObject}->FatalError( Message => "Got no $_!" ); | |
| 34 | + } | |
| 35 | + } | |
| 36 | + | |
| 37 | + # needed objects | |
| 38 | + $Self->{MaintenanceObject} = Kernel::System::Maintenance->new(%Param); | |
| 39 | + $Self->{DateUtils} = Kernel::System::DateUtils->new(%Param); | |
| 40 | + | |
| 41 | + return $Self; | |
| 42 | +} | |
| 43 | + | |
| 44 | +sub Run { | |
| 45 | + my ( $Self, %Param ) = @_; | |
| 46 | + my %Data = (); | |
| 47 | + my $SubAction = $Self->{ParamObject}->GetParam( Param => "Subaction" ); | |
| 48 | + my $Template = 'NewQuickMaintenance'; | |
| 49 | + | |
| 50 | + # common stuff | |
| 51 | + my $StartDateSelectionString = $Self->{LayoutObject}->BuildDateSelection( | |
| 52 | + Format => 'DateInputFormatLong', | |
| 53 | + Prefix => 'StartDate', | |
| 54 | + RequestedTimeOptional => 1, | |
| 55 | + Validate => 1, | |
| 56 | + ); | |
| 57 | + | |
| 58 | + $Data{StartDateSelectionString} = $StartDateSelectionString; | |
| 59 | + | |
| 60 | + if ( $SubAction eq "CreateMaintenance" ) { | |
| 61 | + $Template = "NewMaintenanceCreated"; | |
| 62 | + | |
| 63 | + my $StartDate = $Self->{DateUtils}->GetDateFromParams( Prefix => "StartDate", ParamObject => $Self->{ParamObject} ); | |
| 64 | + my $ScheduledEndDate = $StartDate->clone(); | |
| 65 | + $Self->{DateUtils}->AddDays( Timestamp => $ScheduledEndDate, Days => 1 ); | |
| 66 | + my $Description = $Self->{ParamObject}->GetParam( Param => "Description" ); | |
| 67 | + | |
| 68 | + $Self->{MaintenanceObject}->CreateMaintenance( | |
| 69 | + Description => $Description, | |
| 70 | + StartDate => $Self->{DateUtils}->SQLDate(Timestamp => $StartDate), | |
| 71 | + ScheduledEndDate => $Self->{DateUtils}->SQLDate(Timestamp => $ScheduledEndDate), | |
| 72 | + UserID => $Self->{UserID} | |
| 73 | + ); | |
| 74 | + | |
| 75 | + } | |
| 76 | + else { | |
| 77 | + } | |
| 78 | + | |
| 79 | + # build output | |
| 80 | + my $Output = $Self->{LayoutObject}->Header( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Maintenances") ); | |
| 81 | + $Output .= $Self->{LayoutObject}->NavigationBar(); | |
| 82 | + $Output .= $Self->{LayoutObject}->Output( Data => \%Data, TemplateFile => $Template ); | |
| 83 | + $Output .= $Self->{LayoutObject}->Footer(); | |
| 84 | + return $Output; | |
| 85 | +} | |
| 86 | + | |
| 87 | +sub Debug { | |
| 88 | + my $Self = shift; | |
| 89 | + print STDERR @_; | |
| 90 | +} | |
| 91 | + | |
| 92 | +sub GetDateTime { | |
| 93 | + my ( $Self, %Param ) = @_; | |
| 94 | + my $Prefix = $Param{"Prefix"}; | |
| 95 | + | |
| 96 | + my $Date = sprintf '%04d-%02d-%02d %02d:%02d:00', $Self->{ParamObject}->GetParam( Param => $Prefix . "Year" ), | |
| 97 | + $Self->{ParamObject}->GetParam( Param => $Prefix . "Month" ), | |
| 98 | + $Self->{ParamObject}->GetParam( Param => $Prefix . "Day" ), | |
| 99 | + $Self->{ParamObject}->GetParam( Param => $Prefix . "Hour" ), | |
| 100 | + $Self->{ParamObject}->GetParam( Param => $Prefix . "Minute" ); | |
| 101 | + | |
| 102 | + return $Date; | |
| 103 | +} | |
| 104 | + | |
| 105 | +1; | ... | ... |
| 1 | +++ a/Kernel/Output/HTML/MaintenanceAdvisor.pm | |
| ... | ... | @@ -0,0 +1,68 @@ |
| 1 | +# -- | |
| 2 | +# Kernel/Output/HTML/MaintenanceAdvisor.pm - show maintenances in progress | |
| 3 | +# Copyright (C) 2001-2013 OTRS AG, http://otrs.com/ | |
| 4 | +# -- | |
| 5 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
| 6 | +# the enclosed file COPYING for license information (AGPL). If you | |
| 7 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
| 8 | +# -- | |
| 9 | + | |
| 10 | +package Kernel::Output::HTML::MaintenanceAdvisor; | |
| 11 | + | |
| 12 | +use strict; | |
| 13 | +use warnings; | |
| 14 | +require Kernel::System::Maintenance; | |
| 15 | + | |
| 16 | +sub new { | |
| 17 | + my ( $Type, %Param ) = @_; | |
| 18 | + | |
| 19 | + # allocate new hash for object | |
| 20 | + my $Self = {}; | |
| 21 | + bless( $Self, $Type ); | |
| 22 | + | |
| 23 | + # get needed objects | |
| 24 | + for (qw(ConfigObject LogObject DBObject LayoutObject UserID)) { | |
| 25 | + $Self->{$_} = $Param{$_} || die "Got no $_!"; | |
| 26 | + } | |
| 27 | + $Self->{MaintenanceObject} = Kernel::System::Maintenance->new(%Param); | |
| 28 | + | |
| 29 | + return $Self; | |
| 30 | +} | |
| 31 | + | |
| 32 | +sub Run { | |
| 33 | + my ( $Self, %Param ) = @_; | |
| 34 | + | |
| 35 | + my $TEMPLATE = '<span style="font-weight: bold">%s</span> <span style="margin-right: 50px;">(desde %s)</span>'; | |
| 36 | + | |
| 37 | + my %maintenances = $Self->{MaintenanceObject}->ListCurrentMaintenances(); | |
| 38 | + my $msg = $Self->GetStatus(); | |
| 39 | + | |
| 40 | + # show error notfy, don't work with user id 1 | |
| 41 | + return $Self->{LayoutObject}->Notify( | |
| 42 | + Priority => 'Warning', | |
| 43 | + Link => '', | |
| 44 | + Data => "<div style=\"overflow:hidden\" id=\"maintenanceList\">$msg</div>", | |
| 45 | + ); | |
| 46 | +} | |
| 47 | + | |
| 48 | +sub GetStatus { | |
| 49 | + my ( $Self, %Param ) = @_; | |
| 50 | + | |
| 51 | + my $TEMPLATE = '<span style="float: left; margin-bottom: 10px; margin-right: 50px;">%s<br/>(desde %s)</span> '; | |
| 52 | + | |
| 53 | + my @maintenances = $Self->{MaintenanceObject}->ListCurrentMaintenances(); | |
| 54 | + my $msg = ""; | |
| 55 | + for my $maintenance ( @maintenances ) { | |
| 56 | + $msg .= sprintf( $TEMPLATE, $maintenance->{"Description"}, $maintenance->{"StartDate"} ); | |
| 57 | + } | |
| 58 | + | |
| 59 | + if ( !$msg eq "" ) { | |
| 60 | + $msg = "MANUTENCOES EM ANDAMENTO: <br>" . $msg; | |
| 61 | + } | |
| 62 | + | |
| 63 | + return $msg; | |
| 64 | +} | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | +1; | ... | ... |
| 1 | +++ a/Kernel/Output/HTML/Standard/Maintenances.dtl | |
| ... | ... | @@ -0,0 +1,38 @@ |
| 1 | +# -- | |
| 2 | +# Kernel/Output/HTML/Standard/Maintenances.dtl - template for maintenances module index | |
| 3 | +# Copyright (C) (2014) (Rodrigo Goncalves) (rodrigo.g@ufsc.br) | |
| 4 | +# -- | |
| 5 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
| 6 | +# the enclosed file COPYING for license information (AGPL). If you | |
| 7 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
| 8 | +# -- | |
| 9 | + | |
| 10 | +<table class="DataTable SpacingTop" style="border-collapse: collapse" id="Table"> | |
| 11 | + <thead> | |
| 12 | + <tr> | |
| 13 | + <th><center>$Text{"Actions"}</center></th> | |
| 14 | + <th><center>$Text{"Description"}</center></th> | |
| 15 | + <th><center>$Text{"Start time"}</center></th> | |
| 16 | + </tr> | |
| 17 | + </thead> | |
| 18 | + <tbody> | |
| 19 | + <!-- dtl:block:Maintenance --> | |
| 20 | + <tr> | |
| 21 | + <td><A HREF="$Env{"CGIHandle"}?Action=$Env{"Action"};Subaction=EndMaintenance;ID=$Data{"ID"}">Finalizar</A></td> | |
| 22 | + <td style="border: solid 1px"><center>$Data{"Description"}</center></td> | |
| 23 | + <td style="border: solid 1px"><center><div>$TimeShort{"StartDate"}</div></center></td> | |
| 24 | + </tr> | |
| 25 | + <!-- dtl:block:Maintenance --> | |
| 26 | + </tbody> | |
| 27 | + </table> | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | +<!-- dtl:js_on_document_complete --> | |
| 32 | +<script type="text/javascript"> | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | +</script> | |
| 38 | +<!-- dtl:js_on_document_complete --> | ... | ... |
| 1 | +++ a/Kernel/Output/HTML/Standard/NewMaintenance.dtl | |
| ... | ... | @@ -0,0 +1,69 @@ |
| 1 | +# -- | |
| 2 | +# Kernel/Output/HTML/Standard/NewMaintenance.dtl - template for quickly adding new maintenance | |
| 3 | +# Copyright (C) (2014) (Rodrigo Goncalves) (rodrigo.g@ufsc.br) | |
| 4 | +# -- | |
| 5 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
| 6 | +# the enclosed file COPYING for license information (AGPL). If you | |
| 7 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
| 8 | +# -- | |
| 9 | + | |
| 10 | +<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst"> | |
| 11 | + | |
| 12 | + <h1>$Text{"New maintenance"}</h1> | |
| 13 | + | |
| 14 | + <div class="ContentColumn"> | |
| 15 | + <div class="WidgetSimple"> | |
| 16 | + <div class="Header"> | |
| 17 | + <h2>$Text{"Enter maintenance data"}</h2> | |
| 18 | + </div> | |
| 19 | + <div class="Content SpacingBottom "> | |
| 20 | + | |
| 21 | + <form action="$Env{"CGIHandle"}" method="post" enctype="multipart/form-data" name="form" id="form" class="Validate PreventMultipleSubmits"> | |
| 22 | + | |
| 23 | + <input type="hidden" name="Action" value="$Env{"Action"}"/> | |
| 24 | + <input type="hidden" name="Subaction" value="CreateMaintenance"/> | |
| 25 | + | |
| 26 | + <fieldset class="TableLike"> | |
| 27 | + <label for="StartDate" class="Mandatory"><span class="Marker">*</span>$Text{"Start date"}:</label> | |
| 28 | + <div class="Field"> | |
| 29 | + $Data{"StartDateSelectionString"} | |
| 30 | + </div> | |
| 31 | + <label for="ScheduledEndDate" class="Mandatory"><span class="Marker">*</span>$Text{"Scheduled end date"}:</label> | |
| 32 | + <div class="Field"> | |
| 33 | + $Data{"ScheduledEndDateSelectionString"} | |
| 34 | + </div> | |
| 35 | + | |
| 36 | + <label class="OtherMandatory" for="Description"><span class="Marker">*</span> $Text{"Description"}:</label> | |
| 37 | + <div id="RichTextField" class="RichTextField"> | |
| 38 | + <!-- dtl:block:RichText --> | |
| 39 | + $Include{"RichTextEditor"} | |
| 40 | + <!-- dtl:block:RichText --> | |
| 41 | + <textarea id="Description" class="RichText Validate_Required $QData{"BodyInvalid"}" name="Description" title="Message body">$Data{"Description"}</textarea> | |
| 42 | + <div id="RichTextError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div> | |
| 43 | + <div id="RichTextServerError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div> | |
| 44 | + </div> | |
| 45 | + | |
| 46 | + <label class="OtherMandatory" for="Comments">$Text{"Comments"}:</label> | |
| 47 | + <div id="RichTextField" class="RichTextField"> | |
| 48 | + <!-- dtl:block:RichText --> | |
| 49 | + $Include{"RichTextEditor"} | |
| 50 | + <!-- dtl:block:RichText --> | |
| 51 | + <textarea id="Comments" class="RichText $QData{"BodyInvalid"}" name="Comments" title="Message body">$Data{"Comments"}</textarea> | |
| 52 | + <div id="RichTextError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div> | |
| 53 | + <div id="RichTextServerError" class="TooltipErrorMessage"><p>$Text{"This field is required."}</p></div> | |
| 54 | + </div> | |
| 55 | + | |
| 56 | + <input id='Cadastro' type='submit' value='Cadastrar' style="margin-left: 67%"/> | |
| 57 | + </fieldset> | |
| 58 | + </form> | |
| 59 | + </div> | |
| 60 | + </div> | |
| 61 | + </div> | |
| 62 | +</div> | |
| 63 | + | |
| 64 | + | |
| 65 | +<!-- dtl:js_on_document_complete --> | |
| 66 | +<script type="text/javascript"> | |
| 67 | + | |
| 68 | +</script> | |
| 69 | +<!-- dtl:js_on_document_complete --> | ... | ... |
| 1 | +++ a/Kernel/Output/HTML/Standard/NewMaintenanceCreated.dtl | |
| ... | ... | @@ -0,0 +1,34 @@ |
| 1 | +# -- | |
| 2 | +# Kernel/Output/HTML/Standard/NewMaintenance.dtl - template for quickly adding new maintenance | |
| 3 | +# Copyright (C) (2014) (Rodrigo Goncalves) (rodrigo.g@ufsc.br) | |
| 4 | +# -- | |
| 5 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
| 6 | +# the enclosed file COPYING for license information (AGPL). If you | |
| 7 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
| 8 | +# -- | |
| 9 | + | |
| 10 | +<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst"> | |
| 11 | + | |
| 12 | + <h1>$Text{"New maintenance"}</h1> | |
| 13 | + | |
| 14 | + <div class="ContentColumn"> | |
| 15 | + <div class="WidgetSimple"> | |
| 16 | + <div class="Header"> | |
| 17 | + <h2>$Text{"Enter maintenance data"}</h2> | |
| 18 | + </div> | |
| 19 | + <div class="Content SpacingBottom "> | |
| 20 | + | |
| 21 | + Data: $Data{"StartDate"}<br/> | |
| 22 | + Data fim: $Data{"ScheduledEndDate"}<br/> | |
| 23 | + Descricao: $Data{"Description"} | |
| 24 | + </div> | |
| 25 | + </div> | |
| 26 | + </div> | |
| 27 | +</div> | |
| 28 | + | |
| 29 | + | |
| 30 | +<!-- dtl:js_on_document_complete --> | |
| 31 | +<script type="text/javascript"> | |
| 32 | + | |
| 33 | +</script> | |
| 34 | +<!-- dtl:js_on_document_complete --> | ... | ... |
| 1 | +++ a/Kernel/Output/HTML/Standard/NewQuickMaintenance.dtl | |
| ... | ... | @@ -0,0 +1,50 @@ |
| 1 | +# -- | |
| 2 | +# Kernel/Output/HTML/Standard/NewMaintenance.dtl - template for quickly adding new maintenance | |
| 3 | +# Copyright (C) (2014) (Rodrigo Goncalves) (rodrigo.g@ufsc.br) | |
| 4 | +# -- | |
| 5 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
| 6 | +# the enclosed file COPYING for license information (AGPL). If you | |
| 7 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
| 8 | +# -- | |
| 9 | + | |
| 10 | +<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst"> | |
| 11 | + | |
| 12 | + <h1>$Text{"New maintenance"}</h1> | |
| 13 | + | |
| 14 | + <div class="ContentColumn"> | |
| 15 | + <div class="WidgetSimple"> | |
| 16 | + <div class="Header"> | |
| 17 | + <h2>$Text{"Enter maintenance data"}</h2> | |
| 18 | + </div> | |
| 19 | + <div class="Content SpacingBottom "> | |
| 20 | + | |
| 21 | + <form action="$Env{"CGIHandle"}" method="post" enctype="multipart/form-data" name="form" id="form" class="Validate PreventMultipleSubmits"> | |
| 22 | + | |
| 23 | + <input type="hidden" name="Action" value="$Env{"Action"}"/> | |
| 24 | + <input type="hidden" name="Subaction" value="CreateMaintenance"/> | |
| 25 | + | |
| 26 | + <fieldset class="TableLike"> | |
| 27 | + <label for="StartDate" class="Mandatory"><span class="Marker">*</span>$Text{"Start date"}:</label> | |
| 28 | + <div class="Field"> | |
| 29 | + $Data{"StartDateSelectionString"} | |
| 30 | + </div> | |
| 31 | + | |
| 32 | + <label class="OtherMandatory" for="Description"><span class="Marker">*</span> $Text{"Description"}:</label> | |
| 33 | + <div class="Field"> | |
| 34 | + <textarea style="height: 50px; width: 300px;" id="Description" class="Validate_Required $QData{"BodyInvalid"}" name="Description" title="Message body">$Data{"Description"}</textarea> | |
| 35 | + </div> | |
| 36 | + | |
| 37 | + <input id='Cadastro' type='submit' value='Cadastrar' style="margin-left: 67%"/> | |
| 38 | + </fieldset> | |
| 39 | + </form> | |
| 40 | + </div> | |
| 41 | + </div> | |
| 42 | + </div> | |
| 43 | +</div> | |
| 44 | + | |
| 45 | + | |
| 46 | +<!-- dtl:js_on_document_complete --> | |
| 47 | +<script type="text/javascript"> | |
| 48 | + | |
| 49 | +</script> | |
| 50 | +<!-- dtl:js_on_document_complete --> | ... | ... |
| 1 | +++ a/Kernel/System/DateUtils.pm | |
| ... | ... | @@ -0,0 +1,109 @@ |
| 1 | +# -- | |
| 2 | +# Kernel/System/DateUtils.pm - date/time utils | |
| 3 | +# Copyright (C) (2014) (Rodrigo Goncalves) (rodrigo.g@ufsc.br) | |
| 4 | +# -- | |
| 5 | +# $Id: writing-otrs-application.xml,v 1.1 2010/08/13 08:59:28 mg Exp $ | |
| 6 | +# -- | |
| 7 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
| 8 | +# the enclosed file COPYING for license information (AGPL). If you | |
| 9 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
| 10 | +# -- | |
| 11 | +# Author: Carlos Rebelato | |
| 12 | +# Date..: 19/02/2014 - First version | |
| 13 | +# | |
| 14 | +package Kernel::System::DateUtils; | |
| 15 | + | |
| 16 | +use strict; | |
| 17 | +use warnings; | |
| 18 | +use Data::Dumper; | |
| 19 | +require DateTime; | |
| 20 | + | |
| 21 | +sub new { | |
| 22 | + my ( $Type, %Param ) = @_; | |
| 23 | + | |
| 24 | + # allocate new hash for object | |
| 25 | + my $Self = {%Param}; | |
| 26 | + bless( $Self, $Type ); | |
| 27 | + | |
| 28 | + # creates required objects | |
| 29 | + | |
| 30 | + return $Self; | |
| 31 | +} | |
| 32 | + | |
| 33 | +=item NewTimestamp() | |
| 34 | + | |
| 35 | +Creates a new date from the parameters | |
| 36 | + | |
| 37 | + $ocurrenceObject->NewTimestamp( | |
| 38 | + Year => int, | |
| 39 | + Month => int, | |
| 40 | + Day => int, | |
| 41 | + Hour => int, | |
| 42 | + Minute => int, | |
| 43 | + Second => int | |
| 44 | + ); | |
| 45 | + | |
| 46 | +=cut | |
| 47 | +sub NewTimestamp { | |
| 48 | + my ( $Self, %Param ) = @_; | |
| 49 | + | |
| 50 | + my $date = DateTime->new( | |
| 51 | + year => $Param{Year}, | |
| 52 | + month => $Param{Month}, | |
| 53 | + day => $Param{Day}, | |
| 54 | + hour => $Param{Hour}, | |
| 55 | + minute => $Param{Minute}, | |
| 56 | + second => $Param{Second} | |
| 57 | + ); | |
| 58 | + | |
| 59 | + return $date; | |
| 60 | +} | |
| 61 | +=item AddDays() | |
| 62 | + | |
| 63 | +Adds a number of days to a timestamp | |
| 64 | + | |
| 65 | + $ocurrenceObject->AddDays( | |
| 66 | + Timestamp => DateTime, | |
| 67 | + Days => int | |
| 68 | + ); | |
| 69 | + | |
| 70 | +=cut | |
| 71 | +sub AddDays { | |
| 72 | + my ( $Self, %Param ) = @_; | |
| 73 | + my $timestamp = $Param{Timestamp}; | |
| 74 | + $timestamp->add( days => $Param{Days} ); | |
| 75 | +} | |
| 76 | + | |
| 77 | +=item GetDateFromParams() | |
| 78 | + | |
| 79 | +Create a DateTime based on parameter values | |
| 80 | + | |
| 81 | + $ocurrenceObject->GetDateFromParams( | |
| 82 | + Prefix => string, | |
| 83 | + ParamObject => ParamObject | |
| 84 | + ); | |
| 85 | + | |
| 86 | +=cut | |
| 87 | +sub GetDateFromParams { | |
| 88 | + my ( $Self, %Param ) = @_; | |
| 89 | + my $Prefix = $Param{"Prefix"}; | |
| 90 | + my $ParamObject = $Param{"ParamObject"}; | |
| 91 | + | |
| 92 | + return $Self->NewTimestamp( | |
| 93 | + Year => $ParamObject->GetParam(Param => $Prefix . "Year"), | |
| 94 | + Month => $ParamObject->GetParam(Param => $Prefix . "Month"), | |
| 95 | + Day => $ParamObject->GetParam(Param => $Prefix . "Day"), | |
| 96 | + Hour => $ParamObject->GetParam(Param => $Prefix . "Hour"), | |
| 97 | + Minute => $ParamObject->GetParam(Param => $Prefix . "Minute"), | |
| 98 | + Second => 0 | |
| 99 | + ); | |
| 100 | + | |
| 101 | +} | |
| 102 | + | |
| 103 | +sub SQLDate { | |
| 104 | + my ( $Self, %Param ) = @_; | |
| 105 | + my $timestamp = $Param{"Timestamp"}; | |
| 106 | + return $timestamp->strftime("%y-%m-%d %H:%M:%S"); | |
| 107 | +} | |
| 108 | + | |
| 109 | +1; | ... | ... |
| 1 | +++ a/Kernel/System/Maintenance.pm | |
| ... | ... | @@ -0,0 +1,109 @@ |
| 1 | +# -- | |
| 2 | +# Kernel/System/Maintenanca.pm - maintenance instance | |
| 3 | +# Copyright (C) (2014) (Rodrigo Goncalves) (rodrigo.g@ufsc.br) | |
| 4 | +# -- | |
| 5 | +# $Id: writing-otrs-application.xml,v 1.1 2010/08/13 08:59:28 mg Exp $ | |
| 6 | +# -- | |
| 7 | +# This software comes with ABSOLUTELY NO WARRANTY. For details, see | |
| 8 | +# the enclosed file COPYING for license information (AGPL). If you | |
| 9 | +# did not receive this file, see http://www.gnu.org/licenses/agpl.txt. | |
| 10 | +# -- | |
| 11 | +# Author: Carlos Rebelato | |
| 12 | +# Date..: 19/02/2014 - First version | |
| 13 | +# | |
| 14 | +package Kernel::System::Maintenance; | |
| 15 | + | |
| 16 | +use strict; | |
| 17 | +use warnings; | |
| 18 | +use Data::Dumper; | |
| 19 | + | |
| 20 | +sub new { | |
| 21 | + my ( $Type, %Param ) = @_; | |
| 22 | + | |
| 23 | + # allocate new hash for object | |
| 24 | + my $Self = {%Param}; | |
| 25 | + bless( $Self, $Type ); | |
| 26 | + | |
| 27 | + # creates required objects | |
| 28 | + | |
| 29 | + return $Self; | |
| 30 | +} | |
| 31 | + | |
| 32 | +=item CreateMaintenance() | |
| 33 | + | |
| 34 | +Creates a maintenance | |
| 35 | + | |
| 36 | + $ocurrenceObject->CreateMaintenance( | |
| 37 | + Description => string | |
| 38 | + StartDate => string (format yyyy-mm-dd hh:nn:ss) | |
| 39 | + ScheduledEndDate => string (format yyyy-mm-dd hh:nn:ss) | |
| 40 | + UserID => integer | |
| 41 | + ); | |
| 42 | + | |
| 43 | +=cut | |
| 44 | + | |
| 45 | +sub CreateMaintenance { | |
| 46 | + my ( $Self, %Param ) = @_; | |
| 47 | + | |
| 48 | + for (qw(Description StartDate ScheduledEndDate UserID)) { | |
| 49 | + if ( !$Param{$_} ) { | |
| 50 | + $Self->{LayoutObject}->FatalError( Message => Dumper( \%Param ) . "got no $_!" ); | |
| 51 | + } | |
| 52 | + } | |
| 53 | + | |
| 54 | + $Self->{DBObject}->Do( | |
| 55 | + SQL => "insert into maintenance (description, start_date, scheduled_end_date, user_id) values (?, ?, ?, ?)", | |
| 56 | + Bind => [ \$Param{Description}, \$Param{StartDate}, \$Param{ScheduledEndDate}, \$Param{UserID} ] | |
| 57 | + ); | |
| 58 | +} | |
| 59 | + | |
| 60 | +sub ListCurrentMaintenances { | |
| 61 | + my ( $Self, %Param ) = @_; | |
| 62 | + my @retorno = (); | |
| 63 | + | |
| 64 | + $Self->{DBObject}->Prepare( | |
| 65 | + SQL => | |
| 66 | +"SELECT id,description,start_date FROM maintenance where start_date < CURRENT_TIMESTAMP and end_date = 0 ORDER BY start_date DESC", | |
| 67 | + Bind => [] | |
| 68 | + ); | |
| 69 | + | |
| 70 | + while ( my @row = $Self->{DBObject}->FetchrowArray() ) { | |
| 71 | + my %ret = (); | |
| 72 | + $ret{'Description'} = $row[1]; | |
| 73 | + $ret{'StartDate'} = $row[2]; | |
| 74 | + $ret{'ID'} = $row[0]; | |
| 75 | + push @retorno, \%ret; | |
| 76 | + } | |
| 77 | + | |
| 78 | + return @retorno; | |
| 79 | +} | |
| 80 | + | |
| 81 | +sub EndMaintenance { | |
| 82 | + my ( $Self, %Param ) = @_; | |
| 83 | + | |
| 84 | + $Self->{DBObject}->Prepare( | |
| 85 | + SQL => "UPDATE maintenance SET end_date=CURRENT_TIMESTAMP WHERE id=?", | |
| 86 | + Bind => [ \$Param{ID} ] | |
| 87 | + ); | |
| 88 | + | |
| 89 | +} | |
| 90 | + | |
| 91 | +sub GetStatusID { | |
| 92 | + my ( $Self, %Param ) = @_; | |
| 93 | + my %retorno = (); | |
| 94 | + | |
| 95 | + $Self->{DBObject}->Prepare( | |
| 96 | + SQL => "SELECT count(id), max(id) FROM maintenance where start_date < CURRENT_TIMESTAMP and end_date = 0", | |
| 97 | + Bind => [] | |
| 98 | + ); | |
| 99 | + | |
| 100 | + my @row = $Self->{DBObject}->FetchrowArray(); | |
| 101 | + if ($row[0] != 0) { | |
| 102 | + return ( $row[0], $row[1] ); | |
| 103 | + } | |
| 104 | + else { | |
| 105 | + return ( 0, 0 ); | |
| 106 | + } | |
| 107 | +} | |
| 108 | + | |
| 109 | +1; | ... | ... |
| 1 | +++ a/OTRSMaintenanceManager.sopm | |
| ... | ... | @@ -0,0 +1,72 @@ |
| 1 | +<?xml version="1.0" encoding="utf-8" ?> | |
| 2 | +<otrs_package version="1.0"> | |
| 3 | + <Name>NewTicketWizard</Name> | |
| 4 | + <Version>1.1.4</Version> | |
| 5 | + <Framework>3.x.x</Framework> | |
| 6 | + <Vendor>SeTIC</Vendor> | |
| 7 | + <URL>http://www.setic.ufsc.br</URL> | |
| 8 | + <License>Free</License> | |
| 9 | + <Description Lang="pt-br">Assistente de chamados | |
| 10 | + | |
| 11 | + Versão 1.0.0 - Inicial | |
| 12 | + Versão 1.0.1 - Ajusta listagem de servicos do Service forms, correcao no formulario de edicao de servico | |
| 13 | + Versão 1.0.2 - Ajuste na hierarquia de servicos | |
| 14 | + Versão 1.0.9 - Primeira versao para producao | |
| 15 | + Versão 1.1.1 - Suporte para abertura pública de tickets. | |
| 16 | + Versão 1.1.2 - Suporte para múltiplos domínios. | |
| 17 | + Versão 1.1.3 - Link para abrir segundo chamado na tela de finalização da abertura | |
| 18 | + Versão 1.1.4 - Aumento na fonte do botao de enviar | |
| 19 | + </Description> | |
| 20 | + <IntroInstall Type="post" Lang="pt-br" Title="Obrigado">Módulo instalado com sucesso!</IntroInstall> | |
| 21 | + <Description Lang="en">New Ticket Wizard</Description> | |
| 22 | + <IntroInstall Type="post" Lang="en" Title="Thank you">New Ticket Wizard module installed successfully!</IntroInstall> | |
| 23 | + <BuildDate>?</BuildDate> | |
| 24 | + <BuildHost>?</BuildHost> | |
| 25 | + <Filelist> | |
| 26 | + <File Permission="644" Location="Kernel/Config/Files/NewTicketWizard.xml"></File> | |
| 27 | + <File Permission="644" Location="Kernel/Language/pt_BR_NewTicketWizard.pm"></File> | |
| 28 | + <File Permission="644" Location="Kernel/Modules/NewTicketWizard.pm"></File> | |
| 29 | + <File Permission="644" Location="Kernel/Modules/NewTicketWizardPublic.pm"></File> | |
| 30 | + <File Permission="644" Location="Kernel/Modules/NewTicketWizardServiceForm.pm"></File> | |
| 31 | + | |
| 32 | + <File Permission="644" Location="Kernel/Output/HTML/Standard/NewTicketWizard.dtl"></File> | |
| 33 | + <File Permission="644" Location="Kernel/Output/HTML/Standard/NewTicketWizardPublic.dtl"></File> | |
| 34 | + <File Permission="644" Location="Kernel/Output/HTML/Standard/NewTicketWizardServiceForm.dtl"></File> | |
| 35 | + <File Permission="644" Location="Kernel/Output/HTML/Standard/NewTicketWizardServiceFormEdit.dtl"></File> | |
| 36 | + <File Permission="644" Location="Kernel/Output/HTML/Standard/NewTicketWizardTicketCreated.dtl"></File> | |
| 37 | + <File Permission="644" Location="Kernel/Output/HTML/Standard/NewTicketWizardTicketCreatedPublic.dtl"></File> | |
| 38 | + | |
| 39 | + <File Permission="644" Location="Kernel/System/ServiceForm.pm"></File> | |
| 40 | + <File Permission="644" Location="Kernel/System/TicketWizard.pm"></File> | |
| 41 | + | |
| 42 | + <File Permission="644" Location="var/httpd/htdocs/js/thirdparty/alpaca/alpaca-full.min.js"></File> | |
| 43 | + <File Permission="644" Location="var/httpd/htdocs/js/NewTicketWizard.js"></File> | |
| 44 | + | |
| 45 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/images/alpaca-icons.png"></File> | |
| 46 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/images/date.png"></File> | |
| 47 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/images/down.png"></File> | |
| 48 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/images/email.png"></File> | |
| 49 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/images/left.png"></File> | |
| 50 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/images/phone.png"></File> | |
| 51 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/images/time.png"></File> | |
| 52 | + | |
| 53 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/alpaca-core.min.css"></File> | |
| 54 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/alpaca-extras.min.css"></File> | |
| 55 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/alpaca-jqueryui-newticketwizard.css"></File> | |
| 56 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/alpaca-jqueryui.min.css"></File> | |
| 57 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/alpaca-newticketwizard.css"></File> | |
| 58 | + <File Permission="644" Location="var/httpd/htdocs/skins/Customer/default/css/alpaca/alpaca.min.css"></File> | |
| 59 | + | |
| 60 | + </Filelist> | |
| 61 | + <DatabaseInstall> | |
| 62 | + <TableCreate Name="service_form"> | |
| 63 | + <Column Name="service_id" Required="true" PrimaryKey="true" Type="int"/> | |
| 64 | + <Column Name="introduction" Required="true" Type="text"/> | |
| 65 | + <Column Name="form" Required="true" Type="text"/> | |
| 66 | + <Column Name="form_schema" Required="true" Type="text"/> | |
| 67 | + <ForeignKey ForeignTable="service"> | |
| 68 | + <Reference Local="service_id" Foreign="id"/> | |
| 69 | + </ForeignKey> | |
| 70 | + </TableCreate> | |
| 71 | + </DatabaseInstall> | |
| 72 | +</otrs_package> | |
| 0 | 73 | \ No newline at end of file | ... | ... |
| 1 | +++ a/var/httpd/htdocs/js/maintenance.js | |
| ... | ... | @@ -0,0 +1,51 @@ |
| 1 | +/** | |
| 2 | + * Javascript to indicate maintenances | |
| 3 | + */ | |
| 4 | + | |
| 5 | +var maintenanceManagerLastID = ""; | |
| 6 | +var maintenanceManagerTotalMaintenance = ""; | |
| 7 | + | |
| 8 | +$(document).ready(function() { | |
| 9 | + if ($("#maintenanceList").length) { | |
| 10 | + if ($("#maintenanceList").html() == "") { | |
| 11 | + $("#maintenanceList").parent().hide(); | |
| 12 | + } | |
| 13 | + updateStatusMaintenance(); | |
| 14 | + } | |
| 15 | +}); | |
| 16 | + | |
| 17 | +function updateStatusMaintenance() { | |
| 18 | + setTimeout(function updateStatus() { | |
| 19 | + $.getJSON("/otrs/index.pl?Action=MaintenanceManager;Subaction=StatusID", | |
| 20 | + function parseJSON(data) { | |
| 21 | + var _maintenanceManagerTotalMaintenance = data[0]; | |
| 22 | + var _maintenanceManagerLastID = data[1]; | |
| 23 | + console.log("lastMaintenance=" + _maintenanceManagerLastID + " , totalMaintenance=" + _maintenanceManagerTotalMaintenance); | |
| 24 | + | |
| 25 | + if ((_maintenanceManagerLastID != maintenanceManagerLastID) | |
| 26 | + || (_maintenanceManagerTotalMaintenance != maintenanceManagerTotalMaintenance)) { | |
| 27 | + maintenanceManagerTotalMaintenance = _maintenanceManagerTotalMaintenance; | |
| 28 | + maintenanceManagerLastID = _maintenanceManagerLastID; | |
| 29 | + | |
| 30 | + if (_maintenanceManagerTotalMaintenance == 0) { | |
| 31 | + $("#maintenanceList").html(""); | |
| 32 | + $("#maintenanceList").parent().hide(); | |
| 33 | + updateStatusMaintenance(); | |
| 34 | + } else { | |
| 35 | + $("#maintenanceList").parent().show(); | |
| 36 | + updateContent(); | |
| 37 | + } | |
| 38 | + } | |
| 39 | + }); | |
| 40 | + }, 10000); | |
| 41 | +} | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | +function updateContent() { | |
| 46 | + $.get("/otrs/index.pl?Action=MaintenanceManager;Subaction=Status", | |
| 47 | + function(data) { | |
| 48 | + $("#maintenanceList").html(data); | |
| 49 | + updateStatusMaintenance(); | |
| 50 | + }); | |
| 51 | +} | |
| 0 | 52 | \ No newline at end of file | ... | ... |