<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
    <title></title>
  </head>

  <body>
    Hi there,<br />
    <br />
    another question about RT-Extension-SLA. First of all i must tell you that I´m really a starter with Perl. I have to modify the Extension because we need some kind of "floating" SLA.<br />
    <br />
    When a ticket arrives before 12.00 am it´s necessary to set SLA to next day 23:59:59, if it arrives later than 12.00 am i need to set it two days later 23:59:59.<br />
    <br />
    I used the function SetToMidnight with the due date as Argument. So I´ve tried to get the difference between these two dates, if it is more than 12 hours than the ticket was created later than 12 am, if less, earlier than 12 am.<br />
    <br />
    Here´s some code I´ve started with, so maybe you can tell me how I can finish it ??<br />
    <br />
    <br />
    use strict;<br />
    use warnings;<br />
    <br />
    package RT::Action::SLA_SetFloatingDue;<br />
    use RT::Date;<br />
    use Time::Local;<br />
    <br />
    use base qw(RT::Action::SLA);<br />
    <br />
    =head2 Prepare<br />
    <br />
    Checks if the ticket has service level defined.<br />
    <br />
    =cut<br />
    <br />
    sub Prepare {<br />
        my $self = shift;<br />
    <br />
        unless ( $self->TicketObj->FirstCustomFieldValue('SLA') ) {<br />
            $RT::Logger->error('SLA::SetDue scrip has been applied to ticket #'<br />
                . $self->TicketObj->id . ' that has no SLA defined');<br />
            return 0;<br />
        }<br />
    <br />
        return 1;<br />
     }<br />
    <br />
    <br />
    =head2 Commit<br />
    <br />
    Set the Due date accordingly to SLA.<br />
    <br />
    =cut<br />
    <br />
    sub Commit {<br />
    <br />
            my $self = shift;<br />
    <br />
            my $ticket = $self->TicketObj;<br />
    <br />
            my $due=$ticket->DueObj;<br />
    <br />
            my $midnight = RT::Date::SetToMidnight($due);<br />
            $midnight = $midnight->Unix;<br />
            $due = $due->Unix;<br />
            my $diff = RT::Date::Diff($due,$midnight);<br />
            $RT::Logger->debug("Midnight" . $midnight);<br />
    <br />
            # This is only for test reasons, later we have to change it to correct settings<br />
            return $self->TicketObj->SetDue($due);<br />
    }<br />
    1;<br />
                     <br />
    <br />
    And this is the error message :<br />
    <br />
    [error]: Scrip Commit 25 died. - Undefined subroutine<br />
     &RT::Action::SLA_SetFloatingDue::Diff called at /opt/rt3/local/plugins/RT-Exten<br />
    sion-SLA/lib/RT/Action/SLA_SetFloatingDue.pm line 47.<br />
        <br />
                   <br />
    <br />
  </body>
</html>