Уведомление об эскалации только владельцу заявки

Только для готовых решений! Пожалуйста, не используйте для вопросов и обсуждений!

Модератор: ykolesnikov

Ответить
Aramis
OTRS Новобранец
Сообщения: 15
Зарегистрирован: 12 фев 2013, 11:49

Уведомление об эскалации только владельцу заявки

Сообщение Aramis » 05 апр 2013, 14:35

Создаем файл Kernel/Config/GenericAgentEscalation.pm
с текстом:

Код: Выделить всё

# --
# Kernel/Config/GenericAgentEscalation.pm - config file of generic agent
# Copyright (C) 2011 perl-services.de, http://perl-services.de/
# --
# $Id: GenericAgentEscalation.pm,v 1.1 2011/05/24 15:30:12 rb Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::Config::GenericAgentEscalation;

use strict;
use warnings;

use Encode;

use vars qw($VERSION @ISA @EXPORT %Jobs);
require Exporter;
@ISA     = qw(Exporter);
@EXPORT  = qw(%Jobs);
$VERSION = qw($Revision: 1.1 $) [1];

# -----------------------------------------------------------------------
# config options
# -----------------------------------------------------------------------
%Jobs = (

    # [name of job] -> send escalation notification to ticket owner
    'EscalationToOwner' => {
        Escalation => 1,
        New        => {
            Module => 'Kernel::System::GenericAgent::NotifyOwner',
        },
    },
);

# -----------------------------------------------------------------------
# end of config options
# -----------------------------------------------------------------------

1;

Aramis
OTRS Новобранец
Сообщения: 15
Зарегистрирован: 12 фев 2013, 11:49

Re: Уведомление об эскалации только владельцу заявки

Сообщение Aramis » 05 апр 2013, 14:37

Создаем файл Kernel/System/GenericAgent/NotifyOwner.pm
c текстом:

Код: Выделить всё

# --
# Kernel/System/GenericAgent/NotifyOwner.pm - generic agent notifications
# Copyright (C) 2011 perl-services.de, http://perl-services.de/
# --
# $Id: NotifyOwner.pm,v 1.6 2011/07/25 20:55:55 rb Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (AGPL). If you
# did not receive this file, see http://www.gnu.org/licenses/agpl.txt.
# --

package Kernel::System::GenericAgent::NotifyOwner;

use strict;
use warnings;

use vars qw(@ISA $VERSION);
$VERSION = qw($Revision: 1.6 $) [1];

sub new {
    my ( $Type, %Param ) = @_;

    # allocate new hash for object
    my $Self = {};
    bless( $Self, $Type );

    # check needed objects
    for (qw(DBObject ConfigObject LogObject TicketObject TimeObject EncodeObject)) {
        $Self->{$_} = $Param{$_} || die "Got no $_!";
    }

    # 0=off; 1=on;
    $Self->{Debug} = $Param{Debug} || 0;

    return $Self;
}

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

    # get ticket data
    my %Ticket = $Self->{TicketObject}->TicketGet(%Param);

    if ( !%Ticket ) {
        $Self->{LogObject}->Log(
            Priority => 'notice',
            Message  => 'No Ticket for ' . $Param{TicketID},
        );
        return 1;
    }

    # check if bussines hours is, then send escalation info
    my $CountedTime = $Self->{TimeObject}->WorkingTime(
        StartTime => $Self->{TimeObject}->SystemTime() - ( 10 * 60 ),
        StopTime => $Self->{TimeObject}->SystemTime(),
    );

    if ( !$CountedTime ) {
        if ( $Self->{Debug} ) {
            $Self->{LogObject}->Log(
                Priority => 'debug',
                Message =>
                    "Send not escalation for Ticket $Ticket{TicketNumber}/$Ticket{TicketID} because currently no working hours!",
            );
        }
        return 1;
    }

    # check if it's a escalation of escalation notification
    # check escalation times
    my $EscalationType = '';
    for my $Type (
        qw(FirstResponseTimeEscalation UpdateTimeEscalation SolutionTimeEscalation
        FirstResponseTimeNotification UpdateTimeNotification SolutionTimeNotification)
        )
    {
        if ( defined $Ticket{$Type} ) {
            if ( $Type =~ /TimeEscalation$/ ) {
                $EscalationType = 'Escalation';
                last;
            }
            elsif ( $Type =~ /TimeNotification$/ ) {
                $EscalationType = 'EscalationNotifyBefore';
                last;
            }
        }
    }

    # check
    if ( !$EscalationType ) {
        if ( $Self->{Debug} ) {
            $Self->{LogObject}->Log(
                Priority => 'debug',
                Message =>
                    "Can't send escalation for Ticket $Ticket{TicketNumber}/$Ticket{TicketID} because ticket is not escalated!",
            );
        }
        return;
    }

    # send agent notification
    $Self->{TicketObject}->SendAgentNotification(
        TicketID              => $Param{TicketID},
        CustomerMessageParams => \%Param,
        Type                  => $EscalationType,
        RecipientID           => $Ticket{OwnerID},
        UserID                => 1,
    );

    return 1;
}
в crontab добавляем:

Код: Выделить всё

otrs.GenericAgent.pl -c Kernel::Config::GenericAgentEscalation
Источник: http://forums.otterhub.org/viewtopic.php?f=61&t=8205

Ответить