Not sure of the best way to present my changes. If there is a better way
to code this or present it please let me know.

We monitor our staffs activity by counting the number of closures they
do.
Reporting who closed a ticket can be a problem with the current
ticket_history structure when using "pending close" as the admin is
identified as the change_by. 

I have added a current_owner field (int) to ticket_history table. 

Code changes to History.pm as follows:

# -- Modification:
sub OwnerLookup {
        my $Self = shift;
        my %Param = @_;

        if (!$Param{TicketID}) {
                $Self->{LogObject}->Log(Priority => 'error', Message =>
"OwnerLookup:Need TicketID!");
                return; 
        }
        # check if we ask the same request?
        if (exists
$Self->{"Ticket::History::OwnerLookup::$Param{TicketID}"}) {
                return
$Self->{"Ticket::History::OwnerLookup::$Param{TicketID}"};
        }
        my $SQL = "SELECT user_id FROM ticket WHERE id =
'$Param{TicketID}'";
        $Self->{DBObject}->Prepare(SQL => $SQL);
        while (my @Row = $Self->{DBObject}->FetchrowArray()) {
                # store result          
 
$Self->{"Ticket::History::OwnerLookup::$Param{TicketID}"} = $Row[0];

        }                     
    # check if data exists
    if (!exists
$Self->{"Ticket::History::OwnerLookup::$Param{TicketID}"}) {
        $Self->{LogObject}->Log(Priority => 'error', Message => "No
OwnerLookup for $Param{TicketID} found!");
        return;
    }                  
    else {
        return
$Self->{"Ticket::History::OwnerLookup::$Param{TicketID}"};
    }
}
# --

sub AddHistoryRow {
..
..
    if ((!$Param{OwnerID}) && ($Param{TicketID})) {
        $Param{OwnerID} = $Self->OwnerLookup(TicketID =>
$Param{TicketID});
    }
..
..
        # db insert
    my $SQL = "INSERT INTO ticket_history " .
    " (name, history_type_id, ticket_id, article_id, valid_id, " .
    " create_time, create_by, change_time, change_by,current_owner) " .
        "VALUES " .
    "('$Param{Name}', $Param{HistoryTypeID}, $Param{TicketID}, ".
    " $Param{ArticleID}, $Param{ValidID}, " .
    " current_timestamp, $Param{CreateUserID}, current_timestamp,
$Param{CreateUserID}, $Param{OwnerID})";
..
..
}

Regards,
Nigel

_______________________________________________
OTRS mailing list: dev - Webpage: http://otrs.org/
Archive: http://lists.otrs.org/pipermail/dev
To unsubscribe: http://lists.otrs.org/cgi-bin/listinfo/dev

Reply via email to