Change default escalation_solution_time procedure

English! place to talk about development, programming and coding
Post Reply
jvGgmateev
Znuny newbie
Posts: 4
Joined: 22 Jul 2014, 14:08
Znuny Version: 3.3.6
Company: capsid GmbH

Change default escalation_solution_time procedure

Post by jvGgmateev »

Hello!
I am trying to change the default escalation solution time calculation for a given queue (I repeat, the calculation procedure, not the time itself)

For that I looked into the following classes:
https://github.com/OTRS/otrs/blob/rel-3 ... /Ticket.pm
https://github.com/OTRS/otrs/blob/rel-3 ... em/Time.pm

and I rewrote the method Time::DestinationTime()

Then I integrated it into Ticket around line 2566 and let some debug info flow into the error log. The new calculation worked perfect and the calculated epoch was as expected.

Unfortunately, however, in the end (when I create a the ticket through the form) another timestamp is stored in the database. I don't know where it is coming from.
But I can tell that when I totally replace (put the new DestinationTime() method under the old name so that It is used from everywhere) there is a different integer stored in the database, so it is the same method being used.
Could you please assist me on that, because this is the first thing that I ever do to OTRS and I am not familiar with the whole system. I've been stuck on this for quite a while so any help would be appreciated

Thank you very much in advance!
Best Regards,
Georgi
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Change default escalation_solution_time procedure

Post by reneeb »

It would be great if you could post your changes, what you expect to get and what you get instead.

E.g.

"I modified the subroutine xxxxxx in the file xxxxxxxx:

Code: Select all

... some code (please use the code-tags)...
For a ticket created today at 8:30 am I expect the escalation date xxxx-xx-xx xx:xx:xx, but I get xxxx-xx-xx xx:xx:xx.

For that queue the standard calendar / calendar 8 is selected with these settings (show a screenshot of that calendar)"
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
jvGgmateev
Znuny newbie
Posts: 4
Joined: 22 Jul 2014, 14:08
Znuny Version: 3.3.6
Company: capsid GmbH

Re: Change default escalation_solution_time procedure

Post by jvGgmateev »

Currently I have completely replaced the procedure, just to make sure it is the one being used. The expected calculation is the following:
If the ticket is created during non-working hours - it should do the normal calculation and just add the X number of "working minutes "
If, however, the ticket is created during working hours - the solution time should be set to 17:00 at the next working day.

Code: Select all

sub DestinationTime {
    my ( $Self, %Param ) = @_;

    # "Time zone" diff in seconds
    my $Zone = 0;

    # check needed stuff
    for (qw(StartTime Time)) {
        if ( !defined $Param{$_} ) {
            $Self->{LogObject}->Log( Priority => 'error', Message => "Need $_!" );
            return;
        }
    }
    my $TimeWorkingHours        = $Self->{ConfigObject}->Get('TimeWorkingHours');
    my $TimeVacationDays        = $Self->{ConfigObject}->Get('TimeVacationDays');
    my $TimeVacationDaysOneTime = $Self->{ConfigObject}->Get('TimeVacationDaysOneTime');
    if ( $Param{Calendar} ) {
        if ( $Self->{ConfigObject}->Get( "TimeZone::Calendar" . $Param{Calendar} . "Name" ) ) {
            $TimeWorkingHours
                = $Self->{ConfigObject}->Get( "TimeWorkingHours::Calendar" . $Param{Calendar} );
            $TimeVacationDays
                = $Self->{ConfigObject}->Get( "TimeVacationDays::Calendar" . $Param{Calendar} );
            $TimeVacationDaysOneTime = $Self->{ConfigObject}->Get(
                "TimeVacationDaysOneTime::Calendar" . $Param{Calendar}
            );
            $Zone = $Self->{ConfigObject}->Get( "TimeZone::Calendar" . $Param{Calendar} );
            $Zone = $Zone * 3600;                                                          # 60 * 60
            $Param{StartTime} = $Param{StartTime} + $Zone;
        }
    }
    my $DestinationTime = $Param{StartTime};
    my $CTime           = $Param{StartTime};
    my $CTime2           = $Param{StartTime};
    my $FirstTurn       = 1;
    $Param{Time}++;

    my %LDay = (
        1 => 'Mon',
        2 => 'Tue',
        3 => 'Wed',
        4 => 'Thu',
        5 => 'Fri',
        6 => 'Sat',
        0 => 'Sun',
    );

    my $LoopCounter;
    
    # If start time is NOT in the working hours - follow the standard prodecude
    
    my ( $Second2, $Minute2, $Hour2, $Day2, $Month2, $Year2, $WDay2 ) = localtime $CTime2;  ## no critic
        $Year2  = $Year2 + 1900;
        $Month2 = $Month2 + 1;

    # If start time is NOT in the working hours - follow the standard prodecude
    
        print STDERR $CTime2."\n";
        print STDERR $TimeVacationDays->{$Month2}->{$Day2}."\n";
        print STDERR $TimeVacationDaysOneTime->{$Year2}->{$Month2}->{$Day2}."\n";        
        print STDERR $TimeWorkingHours->{ $LDay{$WDay2} }."\n";
        #print STDERR Dumper(scalar(@{ $TimeVacationDays->{$Month2}->{$Day2}  //[]}))."\n";
        #print STDERR Dumper(scalar(@{ $TimeVacationDaysOneTime->{$Year2}->{$Month2}->{$Day2} //[]}))."\n";
        #print STDERR Dumper(scalar(@{$TimeWorkingHours->{ $LDay{$WDay2} }  //[] }))."\n";
        
    
    if (
        $TimeVacationDays->{$Month2}->{$Day2}
        || $TimeVacationDaysOneTime->{$Year2}->{$Month2}->{$Day2} ||
        !(@{$TimeWorkingHours->{ $LDay{$WDay2} }  //[] })
        )
    {
        
        
        print STDERR "no working day\n";

        while ( $Param{Time} > 1 ) {
            $LoopCounter++;
            last if $LoopCounter > 100;

            my ( $Second, $Minute, $Hour, $Day, $Month, $Year, $WDay ) = localtime $CTime;  ## no critic
            $Year  = $Year + 1900;
            $Month = $Month + 1;

            # Skip vacation days, or days without working hours, do not count.
            if (
                $TimeVacationDays->{$Month}->{$Day}
                || $TimeVacationDaysOneTime->{$Year}->{$Month}->{$Day}
                || !$TimeWorkingHours->{ $LDay{$WDay} }
                )
            {

                if ($FirstTurn) {
                    $DestinationTime = $Self->Date2SystemTime(
                        Year   => $Year,
                        Month  => $Month,
                        Day    => $Day,
                        Hour   => 0,
                        Minute => 0,
                        Second => 0,
                    );
                }
                $DestinationTime = $DestinationTime + 60 * 60 * 24;
                $FirstTurn       = 0;
            }

            # Regular day with working hours
            else {
                for my $H ( $Hour .. 23 ) {

                    # Check if we have a working hour
                    if ( grep { $H == $_ } @{ $TimeWorkingHours->{ $LDay{$WDay} } } ) {
                        if ( $Param{Time} > 60 * 60 ) {
                            if ( $Minute != 0 && $FirstTurn ) {
                                my $Max = 60 - $Minute;
                                $Param{Time} = $Param{Time} - ( $Max * 60 );
                                $DestinationTime = $DestinationTime + ( $Max * 60 );
                                $FirstTurn = 0;
                            }
                            else {
                                $Param{Time} = $Param{Time} - ( 60 * 60 );
                                $DestinationTime = $DestinationTime + ( 60 * 60 );
                                $FirstTurn = 0;
                            }
                        }
                        elsif ( $Param{Time} > 1 * 60 ) {
                            for my $M ( 0 .. 59 ) {
                                if ( $Param{Time} > 1 ) {
                                    $Param{Time}     = $Param{Time} - 60;
                                    $DestinationTime = $DestinationTime + 60;
                                    $FirstTurn       = 0;
                                }
                            }
                        }
                        else {
                            last;
                        }
                    }

                    # Not a working hour
                    else {
                        if ($FirstTurn) {
                            $DestinationTime = $Self->Date2SystemTime(
                                Year   => $Year,
                                Month  => $Month,
                                Day    => $Day,
                                Hour   => $H,
                                Minute => 0,
                                Second => 0,
                            );
                        }
                        if ( $Param{Time} > 59 ) {
                            $DestinationTime = $DestinationTime + ( 60 * 60 );
                        }
                    }
                }
            }

            # Find the unix time stamp for the next day at 00:00:00 to start for calculation.
            my $NewCTime = $Self->Date2SystemTime(
                Year   => $Year,
                Month  => $Month,
                Day    => $Day,
                Hour   => 0,
                Minute => 0,
                Second => 0,
            ) + ( 60 * 60 * 24 );

            # Protect local time zone problems on your machine
            # (e. g. summertime -> wintertime) and not getting over to the next day.
            if ( $NewCTime == $CTime ) {
                $CTime = $CTime + ( 60 * 60 * 24 );

                # reduce destination time diff between today and tomorrow
                my ( $NextSecond, $NextMinute, $NextHour, $NextDay, $NextMonth, $NextYear )
                    = localtime $CTime;    ## no critic
                $NextYear  = $NextYear + 1900;
                $NextMonth = $NextMonth + 1;

                my $Diff = (
                    $Self->Date2SystemTime(
                        Year   => $NextYear,
                        Month  => $NextMonth,
                        Day    => $NextDay,
                        Hour   => 0,
                        Minute => 0,
                        Second => 0,
                        ) - $Self->Date2SystemTime(
                        Year   => $Year,
                        Month  => $Month,
                        Day    => $Day,
                        Hour   => 0,
                        Minute => 0,
                        Second => 0,
                        )
                ) - ( 60 * 60 * 24 );
                $DestinationTime = $DestinationTime - $Diff;
            }

            # Set next loop time to 00:00:00 of next day.
            else {
                $CTime = $NewCTime;
            }
        }
    
    } else {
        print STDERR "working day\n";
        #Find the next working day
        $LoopCounter = 1;
        $CTime2 += 60*60*24;
        while (!$Self->VacationCheckNew(
            Epoch => $CTime2,
            Calendar => $Param{Calendar}
        )) {
            $LoopCounter++;
            last if $LoopCounter > 100;
            $CTime2 += 60*60*24;
            
        }
        print STDERR "$CTime2\n";
    
    #Set time to the next working day 17:00 
         my ( $Second2, $Minute2, $Hour2, $Day2, $Month2, $Year2, $WDay2 ) = localtime $CTime2;
         $DestinationTime = mktime (0,0,19, $Day2, $Month2, $Year2);
         return $DestinationTime - $Zone;
    }

    # return destination time - e. g. with diff of calendar time zone
    return $DestinationTime - $Zone;
}
This is how I tested it

Code: Select all

        # update first response time to expected escalation destination time
        else {

            my $DestinationTime = $Self->{TimeObject}->DestinationTime(
                    StartTime => $Self->{TimeObject}->TimeStamp2SystemTime(
                        String => $Ticket{Created}
                    ),
                    Time     => $Escalation{FirstResponseTime} * 60,
                    Calendar => $Escalation{Calendar},
            );
            print STDERR "Hi noob\n";
            print STDERR $DestinationTime."\n";
            print STDERR "$Escalation{Calendar}\n";
            
            print STDERR "---------------------\n";
            print STDERR "$Ticket{Created}\n";
            
            my $DestinationTimeNew = $Self->{TimeObject}->DestinationTime(
                    StartTime => $Self->{TimeObject}->TimeStamp2SystemTime(
                        String => "2014-07-11 14:00:00"
                    ),
                    Time     => $Escalation{FirstResponseTime} * 60,
                    Calendar => $Escalation{Calendar},
            );
            
            $DestinationTime = $DestinationTimeNew;
            


            
        print STDERR "$DestinationTimeNew asd \n";
output:

Code: Select all

 [error] [client 94.79.155.250] 1404760549, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:49 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 860., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:49 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 861., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] ARRAY(0x357d9b0), referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] working day, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:49 2014] index.pl: Use of uninitialized value in addition (+) at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1147., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1404846949, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] Hi noob, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1404838800, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] ---------------------, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 2014-07-07 21:15:49, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1405080000, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:49 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 860., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:49 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 861., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] ARRAY(0x3521620), referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] working day, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:49 2014] index.pl: Use of uninitialized value in addition (+) at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1147., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:49 2014] index.pl: Use of uninitialized value in addition (+) at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1147., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:49 2014] index.pl: Use of uninitialized value in addition (+) at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1147., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1405339200, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1405357200 asd , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1404760549, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:49 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 860., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:49 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 861., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] ARRAY(0x357d9b0), referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] working day, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:49 2014] index.pl: Use of uninitialized value in addition (+) at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1147., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1404846949, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1404760550, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:50 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 860., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:50 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 861., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] ARRAY(0x357d9b0), referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] working day, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:50 2014] index.pl: Use of uninitialized value in addition (+) at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1147., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1404846950, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1404760549, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:50 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 860., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:50 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 861., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] ARRAY(0x357d9b0), referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] working day, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] [Mon Jul  7 21:15:50 2014] index.pl: Use of uninitialized value in addition (+) at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1147., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
 [error] [client 94.79.155.250] 1404846949, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
And the created ticket:

Code: Select all

[{"id": 827329,"tn": "201407071000456","queue_id": 60,"ticket_lock_id": 1,"ticket_answered": 0,"user_id": 71,"ticket_priority_id": 3,"ticket_state_id": 4,"customer_id": null,"customer_user_id": null,"timeout": 1404760550,"until_time": 0,"valid_id": 1,"create_time_unix": 1404760549,"create_time": "2014-07-07 21:15:49","create_by": 71,"change_time": "2014-07-07 21:15:51","change_by": 71,"title": "Wasdasda sdasd asd","escalation_update_time": 1404838800,"responsible_user_id": 1,"type_id": 1,"service_id": null,"sla_id": null,"escalation_response_time": 0,"escalation_solution_time": 1404838800,"escalation_time": 1404838800,"archive_flag": 0}]
so it's all good, but if I keep the original DestinationTime routine and save the one above as DestinationTimeNew() and call it like this:

Code: Select all

# update first response time to expected escalation destination time
        else {

            my $DestinationTime = $Self->{TimeObject}->DestinationTime(
                    StartTime => $Self->{TimeObject}->TimeStamp2SystemTime(
                        String => $Ticket{Created}
                    ),
                    Time     => $Escalation{FirstResponseTime} * 60,
                    Calendar => $Escalation{Calendar},
            );
            print STDERR "Hi noob\n";
            print STDERR $DestinationTime."\n";
            print STDERR "$Escalation{Calendar}\n";
            
            print STDERR "---------------------\n";
            print STDERR "$Ticket{Created}\n";
            
            my $DestinationTimeNew = $Self->{TimeObject}->DestinationTimeNew(
                    StartTime => $Self->{TimeObject}->TimeStamp2SystemTime(
                        String => "2014-07-11 14:00:00"
                    ),
                    Time     => $Escalation{FirstResponseTime} * 60,
                    Calendar => $Escalation{Calendar},
            );
            
            $DestinationTime = $DestinationTimeNew;
            


            
        print STDERR "$DestinationTimeNew asd \n";
then the output is:

Code: Select all

[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] Hi noob, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] 1406712636, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] 1, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] ---------------------, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] 2014-07-28 15:30:36, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] 1405080000, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] [Mon Jul 28 15:30:36 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1074., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] [Mon Jul 28 15:30:36 2014] index.pl: Use of uninitialized value in concatenation (.) or string at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1075., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] ARRAY(0x3b90aa0), referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] working day, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] [Mon Jul 28 15:30:36 2014] index.pl: Use of uninitialized value in addition (+) at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1361., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] [Mon Jul 28 15:30:36 2014] index.pl: Use of uninitialized value in addition (+) at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1361., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] [Mon Jul 28 15:30:36 2014] index.pl: Use of uninitialized value in addition (+) at /opt/otrs-3.3.6/bin/cgi-bin/../../Kernel/System/Time.pm line 1361., referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] 1405339200, referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicketEmail
[Mon Jul 28 15:30:36 2014] [error] [client 94.79.155.250] 1405357200 asd , referer: https://otrs-test.capsid.com/otrs/index.pl?Action=AgentTicke
And the created object:

Code: Select all

[{"id": 827331,"tn": "201407281000022","queue_id": 60,"ticket_lock_id": 1,"ticket_answered": 0,"user_id": 71,"ticket_priority_id": 3,"ticket_state_id": 4,"customer_id": null,"customer_user_id": null,"timeout": 1406554236,"until_time": 0,"valid_id": 1,"create_time_unix": 1406554236,"create_time": "2014-07-28 15:30:36","create_by": 71,"change_time": "2014-07-28 15:30:36","change_by": 71,"title": "dsgsdfg sdfg sdfg sd","escalation_update_time": 1406712636,"responsible_user_id": 1,"type_id": 1,"service_id": null,"sla_id": null,"escalation_response_time": 0,"escalation_solution_time": 1406712636,"escalation_time": 1406712636,"archive_flag": 0}]
as you can see - the value is being overwritten somewhere. The DestinationTimeNew() calculates the time exactly as expected, but I am seemingly calling it at the wrong place. Any ideas where this has to be done?
reneeb
Znuny guru
Posts: 5018
Joined: 13 Mar 2011, 09:54
Znuny Version: 6.0.x
Real Name: Renée Bäcker
Company: Perl-Services.de
Contact:

Re: Change default escalation_solution_time procedure

Post by reneeb »

Check if e.g. the ticket is moved after the initial creation. The escalation dates are re-calcuated on some events (e.g. ticket moves)... Did you change the method in Ticket.pm that is repsonsible for the calculation as well?
Perl / Znuny development: http://perl-services.de
Free Znuny add ons from the community: http://opar.perl-services.de
Commercial add ons: http://feature-addons.de
jvGgmateev
Znuny newbie
Posts: 4
Joined: 22 Jul 2014, 14:08
Znuny Version: 3.3.6
Company: capsid GmbH

Re: Change default escalation_solution_time procedure

Post by jvGgmateev »

Yes I changed it.

The ticket hasn't been moved afterwards - I am testing in a test environment where only I can login and I had only created the ticket.
jvGgmateev
Znuny newbie
Posts: 4
Joined: 22 Jul 2014, 14:08
Znuny Version: 3.3.6
Company: capsid GmbH

Re: Change default escalation_solution_time procedure

Post by jvGgmateev »

up
Post Reply