
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

Hi Nigel, in OTRS 1.3 (current cvs) you can write a .pm with your own/changed Kernel::System::Ticket functions. Just put your functions in to e. g. Kernel/System/Ticket/Custom.pm and in Kernel/Config.pm: # TicketCustomModule # (custom functions to redefine Kernel::System::Ticket functions) $Self->{TicketCustomModule} = 'Kernel::System::Ticket::Custom'; This way you will overwrite the Kernel::System::Ticket with the functions from your Kernel/System/Ticket/Custom.pm. PS: We also added the OwnerID to the ticket_history table. Thanks for your idea! .-) Martin Edenhofer -- ((otrs.de)) :: OTRS GmbH :: Norsk-Data-Str. 1 :: 61352 Bad Homburg http://www.otrs.de/ :: Manage your communication! On Fri, Aug 06, 2004 at 05:10:52PM +0100, Nigel Clarke wrote:
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
participants (2)
-
Martin Edenhofer
-
Nigel Clarke