[Bps-public-commit] r9468 - in RT-Extension-SLA/lib/RT: Action
sunnavy at bestpractical.com
sunnavy at bestpractical.com
Fri Oct 26 07:59:13 EDT 2007
Author: sunnavy
Date: Fri Oct 26 07:59:10 2007
New Revision: 9468
Modified:
RT-Extension-SLA/lib/RT/Action/SLA_SetStarts.pm
RT-Extension-SLA/lib/RT/Extension/SLA.pm
Log:
initial unique Business::Hours object for each level
Modified: RT-Extension-SLA/lib/RT/Action/SLA_SetStarts.pm
==============================================================================
--- RT-Extension-SLA/lib/RT/Action/SLA_SetStarts.pm (original)
+++ RT-Extension-SLA/lib/RT/Action/SLA_SetStarts.pm Fri Oct 26 07:59:10 2007
@@ -32,7 +32,7 @@
return 1;
}
- my $SLA = $self->Agreements;
+ my $SLA = $self->SLA(Level => $level);
my $starts = $SLA->Starts( $self->TransactionObj->CreatedObj->Unix, $level );
my $date = RT::Date->new($RT::SystemUser);
Modified: RT-Extension-SLA/lib/RT/Extension/SLA.pm
==============================================================================
--- RT-Extension-SLA/lib/RT/Extension/SLA.pm (original)
+++ RT-Extension-SLA/lib/RT/Extension/SLA.pm Fri Oct 26 07:59:10 2007
@@ -160,7 +160,9 @@
sub BusinessHours {
my $self = shift;
require Business::Hours;
- return new Business::Hours;
+ my $bhours = Business::Hours->new;
+ $bhours->business_hours(@_) if @_;
+ return $bhours;
}
sub Agreement {
@@ -186,7 +188,8 @@
}
if ( $args{'Time'} and my $tmp = $meta->{'OutOfHours'}{ $args{'Type'} } ) {
- my $bhours = $self->BusinessHours;
+ my $bhours =
+ $self->BusinessHours($RT::BusinessHours{$meta->{BusinessHours}});
if ( $bhours->first_after( $args{'Time'} ) != $args{'Time'} ) {
foreach ( qw(RealMinutes BusinessMinutes) ) {
next unless $tmp->{ $_ };
@@ -202,13 +205,15 @@
sub Due {
my $self = shift;
my %args = ( Level => undef, Type => undef, Time => undef, @_ );
+ my $meta = $RT::SLA{'Levels'}{ $args{'Level'} };
my $agreement = $self->Agreement( %args );
return undef unless $agreement;
my $res = $args{'Time'};
if ( defined $agreement->{'BusinessMinutes'} ) {
- my $bhours = $self->BusinessHours;
+ my $bhours =
+ $self->BusinessHours(%{$RT::BusinessHours{$meta->{BusinessHours}}});
$res = $bhours->add_seconds( $res, 60 * $agreement->{'BusinessMinutes'} );
}
$res += $agreement->{'RealMinutes'}
@@ -217,6 +222,7 @@
return $res;
}
+
=head2 Agreements [ Type => 'Response' ]
DEPRECATED
@@ -251,6 +257,34 @@
return $SLA;
}
+=head2 SLA [ Level => $level ]
+
+Returns an instance of L<Business::SLA> class filled with the level.
+
+Now we take list of agreements and its description from the
+RT config.
+
+=cut
+
+sub SLA {
+ my $self = shift;
+ my %args = @_;
+ my $level = $args{Level};
+
+ my $class = $RT::SLA{'Module'} || 'Business::SLA';
+ eval "require $class" or die $@;
+
+ my $SLA = $class->new(
+ BusinessHours => $self->BusinessHours(
+ %{ $RT::BusinessHours{ $RT::SLA{Levels}{$level}{BusinessHours} } }
+ )
+ );
+
+ $SLA->Add( $level => %{ $self->Agreement(%args) } );
+
+ return $SLA;
+}
+
sub GetCustomField {
my $self = shift;
my %args = (Ticket => undef, CustomField => 'SLA', @_);
More information about the Bps-public-commit
mailing list