Commit 2f5f1247a75ed9028c1300e0419bd934bbb6efbf

Authored by Rodrigo Gonçalves
1 parent de948f95
Exists in master

Ajustes para o OTRS 4.0.3

DBModel.mwb
No preview for this file type
DBModel.mwb.bak
No preview for this file type
Kernel/Config/Files/MaintenanceManager.xml
... ... @@ -5,15 +5,15 @@
5 5 <ConfigItem Name="Frontend::Module###MaintenanceManager" Required="0" Valid="1">
6 6 <Group>ITSM</Group>
7 7 <SubGroup>MaintenanceManager</SubGroup>
8   - <Description Translatable="1">FrontendModuleRegistration for MaintenanceManager module.</Description>
  8 + <Description>FrontendModuleRegistration for MaintenanceManager module.</Description>
9 9 <Setting>
10 10 <FrontendModuleReg>
11   - <Description Translatable="1">Module for managing maintenances</Description>
  11 + <Description>Module for managing maintenances</Description>
12 12 <NavBarName>MaintenanceManager</NavBarName>
13   - <Title Translatable="1">Maintenances</Title>
  13 + <Title>Maintenances</Title>
14 14 <NavBar>
15   - <Description Translatable="1">Maintenances</Description>
16   - <Name Translatable="1">Maintenances</Name>
  15 + <Description>Maintenances</Description>
  16 + <Name>Maintenances</Name>
17 17 <Link>Action=MaintenanceManager</Link>
18 18 <Block>ItemArea</Block>
19 19 <NavBar>MaintenanceManager</NavBar>
... ... @@ -21,67 +21,30 @@
21 21 <Prio>400</Prio>
22 22 </NavBar>
23 23 <NavBar>
24   - <Description Translatable="1">Maintenances</Description>
25   - <Name Translatable="1">Maintenances</Name>
  24 + <Description>Maintenances</Description>
  25 + <Name>Maintenances</Name>
26 26 <Link>Action=MaintenanceManager</Link>
27 27 <Block>ItemArea</Block>
28 28 <NavBar>MaintenanceManager</NavBar>
29 29 <Type></Type>
30 30 <Prio>400</Prio>
31 31 </NavBar>
32   - <!-- JS/CSS -->
33   - <Loader>
34   - <!--
35   - <JavaScript></JavaScript>
36   - <CSS></CSS>
37   - -->
38   - </Loader>
39 32 </FrontendModuleReg>
40 33 </Setting>
41 34 </ConfigItem>
42   -
43   - <!--
44   - <ConfigItem Name="Frontend::Module###NewMaintenance" Required="1" Valid="1">
45   - <Description Translatable="1">New maintenance</Description>
46   - <Group>ITSM</Group>
47   - <SubGroup>MaintenanceManager</SubGroup>
48   - <Setting>
49   - <FrontendModuleReg>
50   - <Title Translatable="1">New maintenance</Title>
51   - <Group>admin</Group>
52   - <Description>
53   - </Description>
54   - <NavBar>
55   - <Description>New maintenance</Description>
56   - <Name>New maintenance</Name>
57   - <Image>overview.png</Image>
58   - <Link>Action=NewMaintenance</Link>
59   - <NavBar>MaintenanceManager</NavBar>
60   - <Type>
61   - </Type>
62   - <Prio>920</Prio>
63   - <Block>
64   - </Block>
65   - </NavBar>
66   - </FrontendModuleReg>
67   - </Setting>
68   - </ConfigItem>
69   - -->
70 35  
71 36 <ConfigItem Name="Frontend::Module###NewQuickMaintenance" Required="1" Valid="1">
72   - <Description Translatable="1">New quick maintenance</Description>
73   - <!-- usado na configuracao interna (hierarquia) -->
  37 + <Description>New quick maintenance</Description>
74 38 <Group>ITSM</Group>
75 39 <SubGroup>MaintenanceManager</SubGroup>
76   - <!-- usado na configuracao interna (hierarquia) -->
77 40 <Setting>
78 41 <FrontendModuleReg>
79   - <Title Translatable="1">New quick maintenance</Title>
  42 + <Title>New quick maintenance</Title>
80 43 <Group>admin</Group>
81 44 <Description>
82 45 </Description>
83 46 <NavBar>
84   - <Description Translatable="1">New quick maintenance</Description>
  47 + <Description>New quick maintenance</Description>
85 48 <Name>New quick maintenance</Name>
86 49 <Image>overview.png</Image>
87 50 <Link>Action=NewQuickMaintenance</Link>
... ... @@ -97,7 +60,7 @@
97 60 </ConfigItem>
98 61  
99 62 <ConfigItem Name="Frontend::NotifyModule###999-MaintenanceAdvisor" Required="1" Valid="1">
100   - <Description Translatable="1">Defines the module to display maintenances in progress.</Description>
  63 + <Description>Defines the module to display maintenances in progress.</Description>
101 64 <Group>Framework</Group>
102 65 <SubGroup>Frontend::Agent::ModuleNotify</SubGroup>
103 66 <Setting>
... ... @@ -108,7 +71,7 @@
108 71 </ConfigItem>
109 72  
110 73 <ConfigItem Name="Loader::Agent::CommonJS###999-MaintenanceAdvisor" Required="0" Valid="1">
111   - <Description Translatable="1">Maintenance Advisor Warning.</Description>
  74 + <Description>Maintenance Advisor Warning.</Description>
112 75 <Group>Framework</Group>
113 76 <SubGroup>Core::Web</SubGroup>
114 77 <Setting>
... ... @@ -116,7 +79,6 @@
116 79 <Item>maintenance.js</Item>
117 80 </Array>
118 81 </Setting>
119   - </ConfigItem>
120   -
  82 + </ConfigItem>
121 83  
122 84 </otrs_config>
123 85 \ No newline at end of file
... ...
Kernel/Language/pt_BR_MaintenanceManager.pm
1 1 # --
2   -# Kernel/Modules/pt_BR_MaintenanceManager.pm - frontend module for managing maintenances
3   -# Translations
  2 +# Kernel/Modules/pt_BR_MaintenanceManager.pm - translation for frontend module for managing maintenances
4 3 #
5   -# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br)
  4 +# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
  5 +# Version 01/08/2015 - Adjustments for OTRS 4
  6 +#
6 7 # --
7 8 # This software comes with ABSOLUTELY NO WARRANTY. For details, see
8 9 # the enclosed file COPYING for license information (AGPL). If you
... ... @@ -12,9 +13,12 @@ package Kernel::Language::pt_BR_MaintenanceManager;
12 13  
13 14 use strict;
14 15 use warnings;
  16 +use utf8;
15 17  
16 18 sub Data {
17 19 my $Self = shift;
  20 +
  21 + $Self->{Translation}->{'FrontendModuleRegistration for MaintenanceManager module.'} = 'FrontendModuleRegistration para o módulo MaintenanceManager.';
18 22 $Self->{Translation}->{'Maintenances'} = 'Manutenções';
19 23 $Self->{Translation}->{'New maintenance'} = 'Nova manutenção';
20 24 $Self->{Translation}->{'Enter maintenance data'} = 'Informe os dados da manutenção';
... ...
Kernel/Modules/MaintenanceManager.pm
1 1 # --
2 2 # Kernel/Modules/MaintenanceManager.pm - frontend module for manager maintenances
3   -# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br)
  3 +#
  4 +# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
  5 +# Version 01/08/2015 - Adjustments for OTRS 4
  6 +#
4 7 # --
5 8 # This software comes with ABSOLUTELY NO WARRANTY. For details, see
6 9 # the enclosed file COPYING for license information (AGPL). If you
... ... @@ -11,17 +14,12 @@ package Kernel::Modules::MaintenanceManager;
11 14 use strict;
12 15 use warnings;
13 16  
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;
  17 +our @ObjectDependencies = (
  18 +"Kernel::Output::HTML::MaintenanceAdvisor",
  19 +"Kernel::System::Maintenance",
  20 +"Kernel::Output::HTML::Layout",
  21 +"Kernel::System::Web::Request" # OLD ParamObject
  22 +);
25 23  
26 24 sub new {
27 25 my ( $Type, %Param ) = @_;
... ... @@ -30,50 +28,29 @@ sub new {
30 28 my $Self = {%Param};
31 29 bless( $Self, $Type );
32 30  
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 31 return $Self;
55 32 }
56 33  
57   -
58   -
59 34 sub Run {
60 35 my ( $Self, %Param ) = @_;
61 36 my %Data = ();
62   - my $Subaction = $Self->{ParamObject}->GetParam( Param => "Subaction" );
  37 + my $Subaction = $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => "Subaction" );
  38 + my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
  39 + my $MaintenanceObject = $Kernel::OM->Get("Kernel::System::Maintenance");
63 40  
64 41 if ($Subaction eq "EndMaintenance") {
65   - $Self->{MaintenanceObject}->EndMaintenance(ID => $Self->{ParamObject}->GetParam( Param => "ID" ));
  42 + $MaintenanceObject->EndMaintenance(ID => $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => "ID" ));
66 43 } elsif ($Subaction eq "Status") {
67   - return $Self->{LayoutObject}->Attachment(
68   - ContentType => 'text; charset=' . $Self->{LayoutObject}->{Charset},
69   - Content => $Self->{MaintenanceAdvisor}->GetStatus(),
  44 + return $LayoutObject->Attachment(
  45 + ContentType => 'text; charset=' . $LayoutObject->{Charset},
  46 + Content => $Kernel::OM->Get("Kernel::Output::HTML::MaintenanceAdvisor")->GetStatus(),
70 47 Type => 'inline',
71 48 NoCache => 1,
72 49 );
73 50 } elsif ($Subaction eq "StatusID") {
74   - my ($totalMaintenances, $lastMaintenance) = $Self->{MaintenanceObject}->GetStatusID();
75   - return $Self->{LayoutObject}->Attachment(
76   - ContentType => 'application/json; charset=' . $Self->{LayoutObject}->{Charset},
  51 + my ($totalMaintenances, $lastMaintenance) = $MaintenanceObject->GetStatusID();
  52 + return $LayoutObject->Attachment(
  53 + ContentType => 'application/json; charset=' . $LayoutObject->{Charset},
77 54 Content => "[$totalMaintenances, $lastMaintenance]",
78 55 Type => 'inline',
79 56 NoCache => 1,
... ... @@ -81,21 +58,21 @@ sub Run {
81 58 }
82 59  
83 60 # build output
84   - my @maintenances = $Self->{MaintenanceObject}->ListCurrentMaintenances();
  61 + my @maintenances = $MaintenanceObject->ListCurrentMaintenances();
85 62 for my $maintenance ( @maintenances ) {
86   - $Self->{LayoutObject}->Block(
  63 + $LayoutObject->Block(
87 64 Name => 'Maintenance',
88 65 Data => $maintenance,
89 66 );
90 67 }
91 68  
92   - my $Output = $Self->{LayoutObject}->Header( Title => $Self->{LayoutObject}->{LanguageObject}->Get("Maintenances") );
93   - $Output .= $Self->{LayoutObject}->NavigationBar();
94   - $Output .= $Self->{LayoutObject}->Output(
  69 + my $Output = $LayoutObject->Header( Title => $LayoutObject->{LanguageObject}->Translate("Maintenances") );
  70 + $Output .= $LayoutObject->NavigationBar();
  71 + $Output .= $LayoutObject->Output(
95 72 Data => \%Data,
96 73 TemplateFile => 'Maintenances',
97 74 );
98   - $Output .= $Self->{LayoutObject}->Footer();
  75 + $Output .= $LayoutObject->Footer();
99 76 return $Output;
100 77 }
101 78  
... ...
Kernel/Modules/NewMaintenance.pm
1 1 # --
2 2 # Kernel/Modules/NewMaintenance.pm - frontend module for quick adding new maintenances
3   -# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br)
  3 +#
  4 +# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
  5 +# Version 01/08/2015 - Adjustments for OTRS 4
  6 +#
4 7 # --
5 8 # This software comes with ABSOLUTELY NO WARRANTY. For details, see
6 9 # the enclosed file COPYING for license information (AGPL). If you
... ... @@ -11,16 +14,11 @@ package Kernel::Modules::NewMaintenance;
11 14 use strict;
12 15 use warnings;
13 16  
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;
  17 +our @ObjectDependencies = (
  18 +"Kernel::Output::HTML::Layout",
  19 +"Kernel::System::Web::Request", # OLD ParamObject
  20 +"Kernel::System::ITSMChange"
  21 +);
24 22  
25 23 sub new {
26 24 my ( $Type, %Param ) = @_;
... ... @@ -29,51 +27,34 @@ sub new {
29 27 my $Self = {%Param};
30 28 bless( $Self, $Type );
31 29  
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 30 return $Self;
53 31 }
54 32  
55 33 sub Run {
56 34 my ( $Self, %Param ) = @_;
57 35 my %Data = ();
58   - my $SubAction = $Self->{ParamObject}->GetParam( Param => "Subaction" );
  36 + my $ParamObject = $Kernel::OM->Get("Kernel::System::Web::Request");
  37 + my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
  38 +
  39 + my $SubAction = $ParamObject->GetParam( Param => "Subaction" );
59 40 my $Template = 'NewMaintenance';
60 41  
61 42 # common stuff
62   - if ( $Self->{LayoutObject}->{BrowserRichText} ) {
63   - $Self->{LayoutObject}->Block(
  43 + if ( $LayoutObject->{BrowserRichText} ) {
  44 + $LayoutObject->Block(
64 45 Name => 'RichText',
65 46 Data => \%Param,
66 47 );
67 48 }
68 49  
69 50 # Date/time chooses
70   - my $StartDateSelectionString = $Self->{LayoutObject}->BuildDateSelection(
  51 + my $StartDateSelectionString = $LayoutObject->BuildDateSelection(
71 52 Format => 'DateInputFormatLong',
72 53 Prefix => 'StartDate',
73 54 RequestedTimeOptional => 1,
74 55 Validate => 1,
75 56 );
76   - my $ScheduledEndDateSelectionString = $Self->{LayoutObject}->BuildDateSelection(
  57 + my $ScheduledEndDateSelectionString = $LayoutObject->BuildDateSelection(
77 58 Format => 'DateInputFormatLong',
78 59 Prefix => 'ScheduledEndDate',
79 60 RequestedTimeOptional => 1,
... ... @@ -85,12 +66,11 @@ sub Run {
85 66  
86 67 if ( $SubAction eq "CreateMaintenance" ) {
87 68 $Template = "NewMaintenanceCreated";
88   - $Self->Debug( "Params = " . Dumper( $Self->{ParamObject}->GetParamNames() ) );
89 69 $Data{StartDate} = $Self->GetDateTime( Prefix => "StartDate" );
90 70 $Data{ScheduledEndDate} = $Self->GetDateTime( Prefix => "ScheduledEndDate" );
91   - $Data{Description} = $Self->{ParamObject}->GetParam( Param => "Description" );
  71 + $Data{Description} = $ParamObject->GetParam( Param => "Description" );
92 72  
93   - my $ChangeID = $Self->{ChangeObject}->ChangeAdd(
  73 + my $ChangeID = $Kernel::OM->Get("Kernel::System::ITSMChange")->ChangeAdd(
94 74 ChangeTitle => 'Manutenção de serviço', # (optional)
95 75 Description => $Data{Description}, # (optional)
96 76 ChangeStateID => 114, # (optional)
... ... @@ -106,23 +86,18 @@ sub Run {
106 86 }
107 87  
108 88 # 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();
  89 + my $Output = $LayoutObject->Header( Title => $LayoutObject->{LanguageObject}->Translate("Maintenances") );
  90 + $Output .= $LayoutObject->NavigationBar();
  91 + $Output .= $LayoutObject->Output( Data => \%Data, TemplateFile => $Template );
  92 + $Output .= $LayoutObject->Footer();
113 93 return $Output;
114 94 }
115 95  
116   -sub Debug {
117   - my $Self = shift;
118   - print STDERR @_;
119   -}
120   -
121 96 sub GetDateTime {
122 97 my ( $Self, %Param ) = @_;
123 98 my $Prefix = $Param{"Prefix"};
124 99  
125   - my $Date = sprintf '%04d-%02d-%02d %02d:%02d:00', $Self->{ParamObject}->GetParam( Param => $Prefix . "Year" ),
  100 + my $Date = sprintf '%04d-%02d-%02d %02d:%02d:00', $Kernel::OM->Get("Kernel::System::Web::Request")->GetParam( Param => $Prefix . "Year" ),
126 101 $Self->{ParamObject}->GetParam( Param => $Prefix . "Month" ),
127 102 $Self->{ParamObject}->GetParam( Param => $Prefix . "Day" ),
128 103 $Self->{ParamObject}->GetParam( Param => $Prefix . "Hour" ),
... ...
Kernel/Modules/NewQuickMaintenance.pm
1 1 # --
2 2 # Kernel/Modules/NewQuickMaintenance.pm - frontend module for quick adding new maintenances
3   -# Copyright (C) 2014 (Rodrigo Goncalves) (rodrigo.g@ufsc.br)
  3 +#
  4 +# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
  5 +# Version 01/08/2015 - Adjustments for OTRS 4
  6 +#
4 7 # --
5 8 # This software comes with ABSOLUTELY NO WARRANTY. For details, see
6 9 # the enclosed file COPYING for license information (AGPL). If you
... ... @@ -10,12 +13,19 @@ package Kernel::Modules::NewQuickMaintenance;
10 13  
11 14 use strict;
12 15 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);
  16 +use DateTime;
  17 +
  18 +our @ObjectDependencies = (
  19 +"Kernel::System::Maintenance",
  20 +"Kernel::System::DateUtils",
  21 +"Kernel::System::Web::Request", # OLD Param object
  22 +"Kernel::System::DB",
  23 +"Kernel::System::Ticket",
  24 +"Kernel::Output::HTML::Layout", # OLD Layout object
  25 +"Kernel::System::Log",
  26 +"Kernel::System::Queue",
  27 +"Kernel::Config"
  28 +);
19 29  
20 30 sub new {
21 31 my ( $Type, %Param ) = @_;
... ... @@ -24,31 +34,20 @@ sub new {
24 34 my $Self = {%Param};
25 35 bless( $Self, $Type );
26 36  
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 37 return $Self;
42 38 }
43 39  
44 40 sub Run {
45 41 my ( $Self, %Param ) = @_;
46 42 my %Data = ();
47   - my $SubAction = $Self->{ParamObject}->GetParam( Param => "Subaction" );
  43 + my $ParamObject = $Kernel::OM->Get("Kernel::System::Web::Request");
  44 + my $LayoutObject = $Kernel::OM->Get("Kernel::Output::HTML::Layout");
  45 + my $DateUtils = $Kernel::OM->Get("Kernel::System::DateUtils");
  46 +
  47 + my $SubAction = $ParamObject->GetParam( Param => "Subaction" );
48 48 my $Template = 'NewQuickMaintenance';
49 49  
50   - # common stuff
51   - my $StartDateSelectionString = $Self->{LayoutObject}->BuildDateSelection(
  50 + my $StartDateSelectionString = $LayoutObject->BuildDateSelection(
52 51 Format => 'DateInputFormatLong',
53 52 Prefix => 'StartDate',
54 53 RequestedTimeOptional => 1,
... ... @@ -60,44 +59,37 @@ sub Run {
60 59 if ( $SubAction eq "CreateMaintenance" ) {
61 60 $Template = "NewMaintenanceCreated";
62 61  
63   - my $StartDate = $Self->{DateUtils}->GetDateFromParams( Prefix => "StartDate", ParamObject => $Self->{ParamObject} );
  62 + my $StartDate = $DateUtils->GetDateFromParams( Prefix => "StartDate", ParamObject => $ParamObject );
64 63 my $ScheduledEndDate = $StartDate->clone();
65   - $Self->{DateUtils}->AddDays( Timestamp => $ScheduledEndDate, Days => 1 );
66   - my $Description = $Self->{ParamObject}->GetParam( Param => "Description" );
  64 + $DateUtils->AddDays( Timestamp => $ScheduledEndDate, Days => 1 );
  65 + my $Description = $ParamObject->GetParam( Param => "Description" );
67 66  
68   - $Self->{MaintenanceObject}->CreateMaintenance(
  67 + $Kernel::OM->Get("Kernel::System::Maintenance")->CreateMaintenance(
69 68 Description => $Description,
70   - StartDate => $Self->{DateUtils}->SQLDate(Timestamp => $StartDate),
71   - ScheduledEndDate => $Self->{DateUtils}->SQLDate(Timestamp => $ScheduledEndDate),
  69 + StartDate => $DateUtils->SQLDate(Timestamp => $StartDate),
  70 + ScheduledEndDate => $DateUtils->SQLDate(Timestamp => $ScheduledEndDate),
72 71 UserID => $Self->{UserID}
73 72 );
74   -
75   - }
76   - else {
77 73 }
78 74  
79 75 # 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();
  76 + my $Output = $LayoutObject->Header( Title => $LayoutObject->{LanguageObject}->Translate("Maintenances") );
  77 + $Output .= $LayoutObject->NavigationBar();
  78 + $Output .= $LayoutObject->Output( Data => \%Data, TemplateFile => $Template );
  79 + $Output .= $LayoutObject->Footer();
84 80 return $Output;
85 81 }
86 82  
87   -sub Debug {
88   - my $Self = shift;
89   - print STDERR @_;
90   -}
91   -
92 83 sub GetDateTime {
93 84 my ( $Self, %Param ) = @_;
94 85 my $Prefix = $Param{"Prefix"};
  86 + my $ParamObject = $Kernel::OM->Get("Kernel::System::Web::Request");
95 87  
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" );
  88 + my $Date = sprintf '%04d-%02d-%02d %02d:%02d:00', $ParamObject->GetParam( Param => $Prefix . "Year" ),
  89 + $ParamObject->GetParam( Param => $Prefix . "Month" ),
  90 + $ParamObject->GetParam( Param => $Prefix . "Day" ),
  91 + $ParamObject->GetParam( Param => $Prefix . "Hour" ),
  92 + $ParamObject->GetParam( Param => $Prefix . "Minute" );
101 93  
102 94 return $Date;
103 95 }
... ...
Kernel/Output/HTML/MaintenanceAdvisor.pm
1 1 # --
2 2 # Kernel/Output/HTML/MaintenanceAdvisor.pm - show maintenances in progress
3   -# Copyright (C) 2001-2013 OTRS AG, http://otrs.com/
  3 +#
  4 +# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
  5 +# Version 01/08/2015 - Adjustments for OTRS 4
  6 +#
4 7 # --
5 8 # This software comes with ABSOLUTELY NO WARRANTY. For details, see
6 9 # the enclosed file COPYING for license information (AGPL). If you
7 10 # did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
8 11 # --
9   -
10 12 package Kernel::Output::HTML::MaintenanceAdvisor;
11 13  
12 14 use strict;
13 15 use warnings;
14   -require Kernel::System::Maintenance;
15   -require Kernel::System::DateUtils;
  16 +
  17 +our @ObjectDependencies = (
  18 +"Kernel::System::Maintenance",
  19 +"Kernel::System::DateUtils",
  20 +"Kernel::System::DB",
  21 +"Kernel::Output::HTML::Layout", # OLD Layout object
  22 +"Kernel::System::Log",
  23 +"Kernel::Config"
  24 +);
16 25  
17 26 sub new {
18 27 my ( $Type, %Param ) = @_;
... ... @@ -21,13 +30,6 @@ sub new {
21 30 my $Self = {};
22 31 bless( $Self, $Type );
23 32  
24   - # get needed objects
25   - for (qw(ConfigObject LogObject DBObject LayoutObject UserID)) {
26   - $Self->{$_} = $Param{$_} || die "Got no $_!";
27   - }
28   - $Self->{MaintenanceObject} = Kernel::System::Maintenance->new(%Param);
29   - $Self->{DateUtilsObject} = Kernel::System::DateUtils->new(%Param);
30   -
31 33 return $Self;
32 34 }
33 35  
... ... @@ -36,11 +38,10 @@ sub Run {
36 38  
37 39 my $TEMPLATE = '<span style="font-weight: bold">%s</span> <span style="margin-right: 50px;">(desde %s)</span>';
38 40  
39   - my %maintenances = $Self->{MaintenanceObject}->ListCurrentMaintenances();
  41 + my %maintenances = $Kernel::OM->Get("Kernel::System::Maintenance")->ListCurrentMaintenances();
40 42 my $msg = $Self->GetStatus();
41 43  
42   - # show error notfy, don't work with user id 1
43   - return $Self->{LayoutObject}->Notify(
  44 + return $Kernel::OM->Get("Kernel::Output::HTML::Layout")->Notify(
44 45 Priority => 'Warning',
45 46 Link => '',
46 47 Data => "<div style=\"overflow:hidden\" id=\"maintenanceList\">$msg</div>",
... ... @@ -49,24 +50,22 @@ sub Run {
49 50  
50 51 sub GetStatus {
51 52 my ( $Self, %Param ) = @_;
  53 + my $DateUtilsObject = $Kernel::OM->Get("Kernel::System::DateUtils");
52 54  
53 55 my $TEMPLATE = '<span style="float: left; margin-bottom: 10px; margin-right: 50px;">%s<br/>(desde %s)</span> ';
54 56  
55   - my @maintenances = $Self->{MaintenanceObject}->ListCurrentMaintenances();
  57 + my @maintenances = $Kernel::OM->Get("Kernel::System::Maintenance")->ListCurrentMaintenances();
56 58 my $msg = "";
  59 +
57 60 for my $maintenance ( @maintenances ) {
58   - $msg .= sprintf( $TEMPLATE, $maintenance->{"Description"}, $Self->{DateUtilsObject}->BrazilianDate(Timestamp => $Self->{DateUtilsObject}->FromSQL(StringDate => $maintenance->{"StartDate"})) );
  61 + $msg .= sprintf( $TEMPLATE, $maintenance->{"Description"}, $DateUtilsObject->BrazilianDate(Timestamp => $DateUtilsObject->FromSQL(StringDate => $maintenance->{"StartDate"})) );
59 62 }
60 63  
61 64 if ( !$msg eq "" ) {
62   -
63   -
64   - $msg = "<b>" . $Self->{LayoutObject}->{LanguageObject}->Get("Maintenances in progress:") . "</b> <br><br>" . $msg;
  65 + $msg = "<b>" . $Kernel::OM->Get("Kernel::Output::HTML::Layout")->{LanguageObject}->Translate("Maintenances in progress:") . "</b> <br><br>" . $msg;
65 66 }
66 67  
67 68 return $msg;
68 69 }
69 70  
70   -
71   -
72 71 1;
... ...
Kernel/Output/HTML/Standard/Maintenances.dtl
... ... @@ -1,38 +0,0 @@
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><center>$Data{"Description"}</center></td>
23   - <td><center><div>$TimeShort{"$Data{"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 -->
Kernel/Output/HTML/Standard/Maintenances.tt 0 → 100644
... ... @@ -0,0 +1,38 @@
  1 +# --
  2 +# Kernel/Output/HTML/Standard/Maintenances.tt - template for maintenances module index
  3 +#
  4 +# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
  5 +# Version 01/08/2015 - Adjustments 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 +
  13 +<table class="DataTable SpacingTop" style="border-collapse: collapse" id="Table">
  14 + <thead>
  15 + <tr>
  16 + <th><center>[% Translate("Actions") | html %]</center></th>
  17 + <th><center>[% Translate("Description") | html %]</center></th>
  18 + <th><center>[% Translate("Start time") | html %]</center></th>
  19 + </tr>
  20 + </thead>
  21 + <tbody>
  22 + [% RenderBlockStart("Maintenance") %]
  23 + <tr>
  24 + <td><A HREF="[% Env("CGIHandle") %]?Action=[% Env("Action") %];Subaction=EndMaintenance;ID=[% Data.ID %]">Finalizar</A></td>
  25 + <td><center>[% Data.Description %]</center></td>
  26 + <td><center><div>[% Data.StartDate | Localize("TimeShort") %]</div></center></td>
  27 + </tr>
  28 + [% RenderBlockEnd("Maintenance") %]
  29 + </tbody>
  30 + </table>
  31 +
  32 +
  33 +
  34 +[% WRAPPER JSOnDocumentComplete %]
  35 +<script type="text/javascript">
  36 +
  37 +</script>
  38 +[% END %]
... ...
Kernel/Output/HTML/Standard/NewMaintenance.dtl
... ... @@ -1,69 +0,0 @@
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 -->
Kernel/Output/HTML/Standard/NewMaintenance.tt 0 → 100644
... ... @@ -0,0 +1,72 @@
  1 +# --
  2 +# Kernel/Output/HTML/Standard/NewMaintenance.tt - template for quickly adding new maintenance
  3 +#
  4 +# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
  5 +# Version 01/08/2015 - Adjustments 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 +
  13 +<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst">
  14 +
  15 + <h1>[% Translate("New maintenance") | html %]</h1>
  16 +
  17 + <div class="ContentColumn">
  18 + <div class="WidgetSimple">
  19 + <div class="Header">
  20 + <h2>[% Translate("Enter maintenance data") | html %]</h2>
  21 + </div>
  22 + <div class="Content SpacingBottom ">
  23 +
  24 + <form action="[% Env("CGIHandle") %]" method="post" enctype="multipart/form-data" name="form" id="form" class="Validate PreventMultipleSubmits">
  25 +
  26 + <input type="hidden" name="Action" value="[% Env("Action") %]"/>
  27 + <input type="hidden" name="Subaction" value="CreateMaintenance"/>
  28 +
  29 + <fieldset class="TableLike">
  30 + <label for="StartDate" class="Mandatory"><span class="Marker">*</span>[% Translate("Start date") | html %]:</label>
  31 + <div class="Field">
  32 + [% Data.StartDateSelectionString %]
  33 + </div>
  34 + <label for="ScheduledEndDate" class="Mandatory"><span class="Marker">*</span>[% Translate("Scheduled end date") | html %]:</label>
  35 + <div class="Field">
  36 + [% Data.ScheduledEndDateSelectionString %]
  37 + </div>
  38 +
  39 + <label class="OtherMandatory" for="Description"><span class="Marker">*</span> [% Translate("Description") | html %]:</label>
  40 + <div id="RichTextField" class="RichTextField">
  41 + [% RenderBlockStart("RichText") %]
  42 + [% InsertTemplate("RichTextEditor.tt") %]
  43 + [% RenderBlockEnd("RichText") %]
  44 + <textarea id="Description" class="RichText Validate_Required [% Data.BodyInvalid | html %]" name="Description" title="Message body">[% Data.Description %]</textarea>
  45 + <div id="RichTextError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
  46 + <div id="RichTextServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
  47 + </div>
  48 +
  49 + <label class="OtherMandatory" for="Comments">[% Translate("Comments") | html %]:</label>
  50 + <div id="RichTextField" class="RichTextField">
  51 + [% RenderBlockStart("RichText") %]
  52 + [% InsertTemplate("RichTextEditor.tt") %]
  53 + [% RenderBlockEnd("RichText") %]
  54 + <textarea id="Comments" class="RichText [% Data.BodyInvalid | html %]" name="Comments" title="Message body">[% Data.Comments %]</textarea>
  55 + <div id="RichTextError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
  56 + <div id="RichTextServerError" class="TooltipErrorMessage"><p>[% Translate("This field is required.") | html %]</p></div>
  57 + </div>
  58 +
  59 + <input id='Cadastro' type='submit' value='Cadastrar' style="margin-left: 67%"/>
  60 + </fieldset>
  61 + </form>
  62 + </div>
  63 + </div>
  64 + </div>
  65 +</div>
  66 +
  67 +
  68 +[% WRAPPER JSOnDocumentComplete %]
  69 +<script type="text/javascript">
  70 +
  71 +</script>
  72 +[% END %]
... ...
Kernel/Output/HTML/Standard/NewMaintenanceCreated.dtl
... ... @@ -1,28 +0,0 @@
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="Content SpacingBottom ">
17   - Manutenção criada com sucesso.
18   - </div>
19   - </div>
20   - </div>
21   -</div>
22   -
23   -
24   -<!-- dtl:js_on_document_complete -->
25   -<script type="text/javascript">
26   -
27   -</script>
28   -<!-- dtl:js_on_document_complete -->
29 0 \ No newline at end of file
Kernel/Output/HTML/Standard/NewMaintenanceCreated.tt 0 → 100644
... ... @@ -0,0 +1,31 @@
  1 +# --
  2 +# Kernel/Output/HTML/Standard/NewMaintenance.tt - template for quickly adding new maintenance
  3 +#
  4 +# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
  5 +# Version 01/08/2015 - Adjustments 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 +
  13 +<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst">
  14 +
  15 + <h1>[% Translate("New maintenance") | html %]</h1>
  16 +
  17 + <div class="ContentColumn">
  18 + <div class="WidgetSimple">
  19 + <div class="Content SpacingBottom ">
  20 + Manutenção criada com sucesso.
  21 + </div>
  22 + </div>
  23 + </div>
  24 +</div>
  25 +
  26 +
  27 +[% WRAPPER JSOnDocumentComplete %]
  28 +<script type="text/javascript">
  29 +
  30 +</script>
  31 +[% END %]
0 32 \ No newline at end of file
... ...
Kernel/Output/HTML/Standard/NewQuickMaintenance.dtl
... ... @@ -1,48 +0,0 @@
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   - <input type="hidden" name="Action" value="$Env{"Action"}"/>
23   - <input type="hidden" name="Subaction" value="CreateMaintenance"/>
24   -
25   - <fieldset class="TableLike">
26   - <label for="StartDate" class="Mandatory"><span class="Marker">*</span>$Text{"Start date"}:</label>
27   - <div class="Field">
28   - $Data{"StartDateSelectionString"}
29   - </div>
30   -
31   - <label class="OtherMandatory" for="Description"><span class="Marker">*</span> $Text{"Description"}:</label>
32   - <div class="Field">
33   - <textarea style="height: 50px; width: 400px;" id="Description" class="Validate_Required $QData{"BodyInvalid"}" name="Description" title="Message body">$Data{"Description"}</textarea>
34   - </div>
35   - </fieldset>
36   - <input id='Cadastro' type='submit' value='$Text{"Start"}' style="margin-left: 50%"/>
37   - </form>
38   - </div>
39   - </div>
40   - </div>
41   -</div>
42   -
43   -
44   -<!-- dtl:js_on_document_complete -->
45   -<script type="text/javascript">
46   -
47   -</script>
48   -<!-- dtl:js_on_document_complete -->
Kernel/Output/HTML/Standard/NewQuickMaintenance.tt 0 → 100644
... ... @@ -0,0 +1,51 @@
  1 +# --
  2 +# Kernel/Output/HTML/Standard/NewMaintenance.tt - template for quickly adding new maintenance
  3 +#
  4 +# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
  5 +# Version 01/08/2015 - Adjustments 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 +
  13 +<div class="MainBox ARIARoleMain LayoutFixedSidebar SidebarFirst">
  14 +
  15 + <h1>[% Translate("New maintenance") | html %]</h1>
  16 +
  17 + <div class="ContentColumn">
  18 + <div class="WidgetSimple">
  19 + <div class="Header">
  20 + <h2>[% Translate("Enter maintenance data") | html %]</h2>
  21 + </div>
  22 + <div class="Content SpacingBottom ">
  23 +
  24 + <form action="[% Env("CGIHandle") %]" method="post" enctype="multipart/form-data" name="form" id="form" class="Validate PreventMultipleSubmits">
  25 + <input type="hidden" name="Action" value="[% Env("Action") %]"/>
  26 + <input type="hidden" name="Subaction" value="CreateMaintenance"/>
  27 +
  28 + <fieldset class="TableLike">
  29 + <label for="StartDate" class="Mandatory"><span class="Marker">*</span>[% Translate("Start date") | html %]:</label>
  30 + <div class="Field">
  31 + [% Data.StartDateSelectionString %]
  32 + </div>
  33 +
  34 + <label class="OtherMandatory" for="Description"><span class="Marker">*</span> [% Translate("Description") | html %]:</label>
  35 + <div class="Field">
  36 + <textarea style="height: 50px; width: 400px;" id="Description" class="Validate_Required [% Data.BodyInvalid | html %]" name="Description" title="Message body">[% Data.Description %]</textarea>
  37 + </div>
  38 + </fieldset>
  39 + <input id='Cadastro' type='submit' value='[% Translate("Start") | html %]' style="margin-left: 50%"/>
  40 + </form>
  41 + </div>
  42 + </div>
  43 + </div>
  44 +</div>
  45 +
  46 +
  47 +[% WRAPPER JSOnDocumentComplete %]
  48 +<script type="text/javascript">
  49 +
  50 +</script>
  51 +[% END %]
... ...
Kernel/System/DateUtils.pm
1 1 # --
2 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   -# --
  3 +#
  4 +# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
  5 +# Version 01/08/2015 - Adjustments for OTRS 4
  6 +#
7 7 # This software comes with ABSOLUTELY NO WARRANTY. For details, see
8 8 # the enclosed file COPYING for license information (AGPL). If you
9 9 # did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
10 10 # --
11   -# Author: Carlos Rebelato
12   -# Date..: 19/02/2014 - First version
13 11 #
14 12 package Kernel::System::DateUtils;
15 13  
... ... @@ -19,6 +17,8 @@ use Data::Dumper;
19 17 require DateTime;
20 18 use Time::Piece;
21 19  
  20 +our @ObjectDependencies = ();
  21 +
22 22 sub new {
23 23 my ( $Type, %Param ) = @_;
24 24  
... ... @@ -26,8 +26,6 @@ sub new {
26 26 my $Self = {%Param};
27 27 bless( $Self, $Type );
28 28  
29   - # creates required objects
30   -
31 29 return $Self;
32 30 }
33 31  
... ... @@ -116,7 +114,6 @@ sub BrazilianDate {
116 114 sub FromSQL {
117 115 my ( $Self, %Param ) = @_;
118 116 my $timestamp = $Param{"StringDate"};
119   - print STDERR $timestamp;
120 117 return Time::Piece->strptime($timestamp, "%Y-%m-%d %H:%M:%S");
121 118 }
122 119  
... ...
Kernel/System/Maintenance.pm
1 1 # --
2 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   -# --
  3 +#
  4 +# Copyright (C) 2014 SeTIC - UFSC - http://setic.ufsc.br/
  5 +# Version 01/08/2015 - Adjustments for OTRS 4
  6 +#
7 7 # This software comes with ABSOLUTELY NO WARRANTY. For details, see
8 8 # the enclosed file COPYING for license information (AGPL). If you
9 9 # did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
10 10 # --
11   -# Author: Carlos Rebelato
12   -# Date..: 19/02/2014 - First version
13 11 #
14 12 package Kernel::System::Maintenance;
15 13  
... ... @@ -17,6 +15,19 @@ use strict;
17 15 use warnings;
18 16 use Data::Dumper;
19 17  
  18 +
  19 +our @ObjectDependencies = (
  20 +"Kernel::System::DB",
  21 +"Kernel::Output::HTML::Layout", # OLD Layout object
  22 +
  23 +"Kernel::System::Maintenance",
  24 +"Kernel::System::DateUtils",
  25 +
  26 +"Kernel::System::Log",
  27 +"Kernel::Config"
  28 +);
  29 +
  30 +
20 31 sub new {
21 32 my ( $Type, %Param ) = @_;
22 33  
... ... @@ -24,8 +35,6 @@ sub new {
24 35 my $Self = {%Param};
25 36 bless( $Self, $Type );
26 37  
27   - # creates required objects
28   -
29 38 return $Self;
30 39 }
31 40  
... ... @@ -47,11 +56,11 @@ sub CreateMaintenance {
47 56  
48 57 for (qw(Description StartDate ScheduledEndDate UserID)) {
49 58 if ( !$Param{$_} ) {
50   - $Self->{LayoutObject}->FatalError( Message => Dumper( \%Param ) . "got no $_!" );
  59 + $Kernel::OM->Get("Kernel::Output::HTML::Layout")->FatalError( Message => Dumper( \%Param ) . "got no $_!" );
51 60 }
52 61 }
53 62  
54   - $Self->{DBObject}->Do(
  63 + $Kernel::OM->Get("Kernel::System::DB")->Do(
55 64 SQL => "insert into maintenance (description, start_date, scheduled_end_date, user_id) values (?, ?, ?, ?)",
56 65 Bind => [ \$Param{Description}, \$Param{StartDate}, \$Param{ScheduledEndDate}, \$Param{UserID} ]
57 66 );
... ... @@ -61,13 +70,13 @@ sub ListCurrentMaintenances {
61 70 my ( $Self, %Param ) = @_;
62 71 my @retorno = ();
63 72  
64   - $Self->{DBObject}->Prepare(
  73 + $Kernel::OM->Get("Kernel::System::DB")->Prepare(
65 74 SQL =>
66 75 "SELECT id,description,start_date FROM maintenance where start_date < CURRENT_TIMESTAMP and COALESCE(end_date,0) = 0 ORDER BY start_date DESC, id asc",
67 76 Bind => []
68 77 );
69 78  
70   - while ( my @row = $Self->{DBObject}->FetchrowArray() ) {
  79 + while ( my @row = $Kernel::OM->Get("Kernel::System::DB")->FetchrowArray() ) {
71 80 my %ret = ();
72 81 $ret{'ID'} = $row[0];
73 82 $ret{'Description'} = $row[1];
... ... @@ -81,7 +90,7 @@ sub ListCurrentMaintenances {
81 90 sub EndMaintenance {
82 91 my ( $Self, %Param ) = @_;
83 92  
84   - $Self->{DBObject}->Prepare(
  93 + $Kernel::OM->Get("Kernel::System::DB")->Prepare(
85 94 SQL => "UPDATE maintenance SET end_date=CURRENT_TIMESTAMP WHERE id=?",
86 95 Bind => [ \$Param{ID} ]
87 96 );
... ... @@ -92,12 +101,12 @@ sub GetStatusID {
92 101 my ( $Self, %Param ) = @_;
93 102 my %retorno = ();
94 103  
95   - $Self->{DBObject}->Prepare(
  104 + $Kernel::OM->Get("Kernel::System::DB")->Prepare(
96 105 SQL => "SELECT count(id), max(id) FROM maintenance where start_date < CURRENT_TIMESTAMP and COALESCE(end_date,0) = 0",
97 106 Bind => []
98 107 );
99 108  
100   - my @row = $Self->{DBObject}->FetchrowArray();
  109 + my @row = $Kernel::OM->Get("Kernel::System::DB")->FetchrowArray();
101 110 if ($row[0] != 0) {
102 111 return ( $row[0], $row[1] );
103 112 }
... ...
MaintenanceManager.sopm
1 1 <?xml version="1.0" encoding="utf-8" ?>
2 2 <otrs_package version="1.0">
3 3 <Name>MaintenanceManager</Name>
4   - <Version>1.0.2</Version>
5   - <Framework>3.x.x</Framework>
  4 + <Version>1.1.0</Version>
  5 + <Framework>4.0.3</Framework>
6 6 <Vendor>SeTIC</Vendor>
7   - <URL>http://www.setic.ufsc.br</URL>
8   - <License>Free</License>
9   - <Description Lang="pt-br">Gerenciador de manutenções
10   -
11   - Versão 1.0 - Inicial - suporte a aviso de manutenções rápidas
12   - </Description>
13   - <IntroInstall Type="post" Lang="pt-br" Title="Obrigado">Módulo instalado com sucesso!</IntroInstall>
14   - <Description Lang="en">New Ticket Wizard</Description>
15   - <IntroInstall Type="post" Lang="en" Title="Thank you">OTRS Maintenance Manager Module installed successfully!</IntroInstall>
  7 + <URL>http://setic.ufsc.br</URL>
  8 + <License>GPLv2</License>
  9 + <ChangeLog Version="1.1.0">Adjustments for OTRS 4.0.3</ChangeLog>
  10 + <Description>Maintenance Manager</Description>
  11 +
  12 + <IntroInstall Type="post" Title="Thank you">Maintenance Manager Module installed successfully!</IntroInstall>
  13 +
16 14 <BuildDate>?</BuildDate>
17 15 <BuildHost>?</BuildHost>
  16 +
18 17 <Filelist>
19 18 <File Permission="644" Location="Kernel/Config/Files/MaintenanceManager.xml"></File>
20 19 <File Permission="644" Location="Kernel/Language/pt_BR_MaintenanceManager.pm"></File>
21 20 <File Permission="644" Location="Kernel/Modules/MaintenanceManager.pm"></File>
22 21 <File Permission="644" Location="Kernel/Modules/NewMaintenance.pm"></File>
23 22 <File Permission="644" Location="Kernel/Modules/NewQuickMaintenance.pm"></File>
24   - <File Permission="644" Location="Kernel/Output/HTML/Standard/Maintenances.dtl"></File>
25   - <File Permission="644" Location="Kernel/Output/HTML/Standard/NewMaintenance.dtl"></File>
26   - <File Permission="644" Location="Kernel/Output/HTML/Standard/NewMaintenanceCreated.dtl"></File>
27   - <File Permission="644" Location="Kernel/Output/HTML/Standard/NewQuickMaintenance.dtl"></File>
  23 + <File Permission="644" Location="Kernel/Output/HTML/Standard/Maintenances.tt"></File>
  24 + <File Permission="644" Location="Kernel/Output/HTML/Standard/NewMaintenance.tt"></File>
  25 + <File Permission="644" Location="Kernel/Output/HTML/Standard/NewMaintenanceCreated.tt"></File>
  26 + <File Permission="644" Location="Kernel/Output/HTML/Standard/NewQuickMaintenance.tt"></File>
28 27 <File Permission="644" Location="Kernel/Output/HTML/MaintenanceAdvisor.pm"></File>
29 28 <File Permission="644" Location="Kernel/System/DateUtils.pm"></File>
30 29 <File Permission="644" Location="Kernel/System/Maintenance.pm"></File>
... ...
script.sql
... ... @@ -1 +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);
script.sql~
... ... @@ -1 +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);