I do the the same think in a plugin. The best solution to get these informations is to use TicketSearch function.

Attached files are a sample of code with this function.
/otrs/Kernel/Config/Files/GenetelSearchConfig.pm <cid:[email protected]> /otrs/Kernel/Modules/GenetelSearch.pm <cid:[email protected]>
These scripts needs others no provided scripts.

Cordialement / Regards

Alexandre FOUREY
Consultant
[EMAIL PROTECTED]
Cell Phone 33 (0)6 67 67 50 12


/otrs/Kernel/Config/Files/GenetelSearchConfig.pm <cid:[email protected]>
Florent Guiliani wrote:

Martin Edenhofer a écrit :

Hi Florent,

(it would be fine if you use just on list in the To: field. thanks)
Ok

Florent Guiliani schrieb:

Is it possible to search for any ticket who have been closed in a laps
of time?


No, it's not possible.
Is it possible for me to add this feature under a plugin?

If I add the feature in the core, do you accept patch to include in official release ?

Another question: Is is possible to see all tickets locked on a given
user ?


No, it's not possible.
Same questions..

 Martin
Thank you Martin. I'm evaluating OTRS for my company (www.perinfo.com). Some features are missing. I can code but not for a long time. I hope API is well formed and documented ;).

Florent,

_______________________________________________
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

    $Self->{'Frontend::Module'}->{'GenetelSearch'} = {
        Description => 'Advanced Search',
        Title => 'Recherche avancée',
        NavBarName => 'Ticket',
        NavBar => [
            {
                Description => 'Advanced Search',
                Name => 'Recherche avancée',
                Image => 'search.png',
                Link => 'Action=GenetelSearch',
                NavBar => 'Ticket',
                Prio => 310,
            },
        ],
    };
    $Self->{'Frontend::Module'}->{'=GenetelSearch'} = {
        Description => 'Advanced Search',
        Title => 'Recherche avancée',
        NavBarName => 'Ticket',
    };
# --
# Kernel/Modules/AgentTicketAutoSearch.pm -
# Copyright (C) 2001-2005 Alexandre FOUREY <[EMAIL PROTECTED]>
# --
# $Id: AgentTicketAutoSearch.pm,v 1.0 2005/10/13 19:17:33 Alexandre Exp $
# --
# This software comes with ABSOLUTELY NO WARRANTY. For details, see
# the enclosed file COPYING for license information (GPL). If you
# did not receive this file, see http://www.gnu.org/licenses/gpl.txt.
# --

package Kernel::Modules::GenetelSearch;

use strict;
use Kernel::System::Time;
use Kernel::System::GenetelRapportSystem;

use vars qw($VERSION);
$VERSION = '$Revision: 1.0 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;



my $ConfigObject = Kernel::Config->new();
my $LogObject    = Kernel::System::Log->new(
    ConfigObject => $ConfigObject,
);

my $DBObject = Kernel::System::DB->new(
    ConfigObject => $ConfigObject,
    LogObject => $LogObject,
);

# --
sub new {
    my $Type = shift;
    my %Param = @_;

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

    foreach (keys %Param) {
        
        $Self->{$_} = $Param{$_};
    }

    # check needed Opjects
    foreach (qw(ParamObject DBObject TicketObject LayoutObject LogObject 
ConfigObject)) {
        $Self->{$_} = $Param{$_} || $Self->{LayoutObject}->FatalError(Message 
=> "Got no $_!");
    }
    
    # check time object
    $Self->{TimeObject} = Kernel::System::Time->new(
                     ConfigObject => Kernel::Config->new(),
    );
    $Self->{RapportObject} = Kernel::System::GenetelRapportSystem->new(%Param);
    return $Self;
}
# --
sub Run {
    my $Self = shift;
    my %Param = @_;
    my $Output;

    # --
    # check needed stuff
    # --
    
    # --
    # Print form
    # --
    #
    if ($Self->{Subaction} eq 'SearchAge') {
        # print form
        $Output .= $Self->{LayoutObject}->Header(Value => "Genetel");
        $Output .= $Self->{LayoutObject}->NavigationBar();

        my %Ticket;
        
        my @ViewableIDs = $Self->TicketSearchAge(
                Subject => $Self->{Title},
                Days    => $Self->{ParamObject}->GetParam(Param => 'Days'),
                Hours   => $Self->{ParamObject}->GetParam(Param => 'Hours'),
        );
        foreach my $ID (@ViewableIDs) {
                my %IDGet = $Self->{TicketObject}->TicketGet(
                        TicketID => $ID,
                );
                my @IDHistory = $Self->{TicketObject}->HistoryGet(
                        UserID => 1,
                        TicketID => $ID,
                );
                #$Self->{LogObject}->Log(Priority => 'notice', Message => 
"GENETEL TicketSearch - Found Ticket $IDGet{TicketNumber}");
                my $ModSysTime=$Self->{TimeObject}->SystemTime();
                my $ModTime=$Self->{TimeObject}->SystemTime();
                foreach (@IDHistory) {
                        if ($_->{"HistoryType"} eq "Lock") {next};
                        if ($_->{"HistoryType"} eq "Unlock") {next};
                        if ($_->{"HistoryType"} eq "Misc") {next};
                        $ModTime = $_->{"CreateTime"};
                        $ModSysTime = 
$Self->{TimeObject}->TimeStamp2SystemTime(String => $_->{"CreateTime"},);
                        #$Self->{LogObject}->Log(Priority => 'notice', Message 
=> "GENETEL TicketSearch - Set ModTime $ModTime $ModSysTime");
                }
                
                my $RefTime = $Self->{TimeObject}->SystemTime() - ( 
$Self->{ParamObject}->GetParam(Param => 'Hours') * 3600 );
                
                #$Self->{LogObject}->Log(Priority => 'notice', Message => 
"GENETEL TicketSearch - TimeValidation $RefTime $ModSysTime");
                
                if ($ModSysTime > $RefTime) {next};
                
                if ($IDGet{"Lock"} eq "lock") {
                        $IDGet{"Lock"}="Oui";
                } else {
                        $IDGet{"Lock"}="Non";
                }
                
                $Self->{LayoutObject}->Block(
                        Name => 'Tickets',
                        Data => {
                                ID => $IDGet{TicketID},
                                TN => $IDGet{TicketNumber},
                                Categorie => $IDGet{TicketFreeText8},
                                Priority => $IDGet{Priority},
                                Title => $IDGet{Title},
                                Created => $IDGet{Created},
                                Changed => $ModTime,
                                State => $IDGet{State},
                                Lock => $IDGet{Lock},
                                Owner => $IDGet{Owner},
                                CClient => $IDGet{CustomerID},
                        },
                );      
        }
        $Output .= $Self->{LayoutObject}->Output(
                TemplateFile => 'GenetelSearchResult',
                Data => { %Ticket },
        );
        $Output .= $Self->{LayoutObject}->Footer();
        return $Output;
    }elsif ($Self->{Subaction} eq 'SearchCustomer') {
        # print form
        $Output .= $Self->{LayoutObject}->Header(Value => "Genetel");
        $Output .= $Self->{LayoutObject}->NavigationBar();

        my %Ticket;
        
        my @ViewableIDs = $Self->TicketSearchCustomer(
                Subject => $Self->{Title},
                Customer => $Self->{ParamObject}->GetParam(Param => 'Customer'),
        );
        foreach my $ID (@ViewableIDs) {
                my %IDGet = $Self->{TicketObject}->TicketGet(
                        TicketID => $ID,
                );
                my @IDHistory = $Self->{TicketObject}->HistoryGet(
                        UserID => 1,
                        TicketID => $ID,
                );
                #$Self->{LogObject}->Log(Priority => 'notice', Message => 
"GENETEL TicketSearch - Found Ticket $IDGet{TicketNumber}");
                my $ModSysTime=$Self->{TimeObject}->SystemTime();
                my $ModTime=$Self->{TimeObject}->SystemTime();
                foreach (@IDHistory) {
                        if ($_->{"HistoryType"} eq "Lock") {next};
                        if ($_->{"HistoryType"} eq "Unlock") {next};
                        if ($_->{"HistoryType"} eq "Misc") {next};
                        $ModTime = $_->{"CreateTime"};
                        $ModSysTime = 
$Self->{TimeObject}->TimeStamp2SystemTime(String => $_->{"CreateTime"},);
                        #$Self->{LogObject}->Log(Priority => 'notice', Message 
=> "GENETEL TicketSearch - Set ModTime $ModTime $ModSysTime");
                }
                
                my $RefTime = $Self->{TimeObject}->SystemTime() - ( 
$Self->{ParamObject}->GetParam(Param => 'Hours') * 3600 );
                
                #$Self->{LogObject}->Log(Priority => 'notice', Message => 
"GENETEL TicketSearch - TimeValidation $RefTime $ModSysTime");
                
                if ($ModSysTime > $RefTime) {next};
                
                if ($IDGet{"Lock"} eq "lock") {
                        $IDGet{"Lock"}="Oui";
                } else {
                        $IDGet{"Lock"}="Non";
                }
                
                $Self->{LayoutObject}->Block(
                        Name => 'Tickets',
                        Data => {
                                ID => $IDGet{TicketID},
                                TN => $IDGet{TicketNumber},
                                Categorie => $IDGet{TicketFreeText8},
                                Priority => $IDGet{Priority},
                                Title => $IDGet{Title},
                                Created => $IDGet{Created},
                                Changed => $ModTime,
                                State => $IDGet{State},
                                Lock => $IDGet{Lock},
                                Owner => $IDGet{Owner},
                                CClient => $IDGet{CustomerID},
                        },
                );      
        }
        $Output .= $Self->{LayoutObject}->Output(
                TemplateFile => 'GenetelSearchResult',
                Data => { %Ticket },
        );
        $Output .= $Self->{LayoutObject}->Footer();
        return $Output;
    } else {
        # print form
        $Output .= $Self->{LayoutObject}->Header(Value => "Genetel");
        $Output .= $Self->{LayoutObject}->NavigationBar();
        #

        my %DayList;
        for (my $D=1;$D<=20;$D++) {
            my $D1=$D;
            if ($D<10) {$D1="0".$D};
            $DayList{$D} = $D1;
        }
        my %HourList;
        for (my $D=1;$D<=24;$D++) {
            my $D1=$D;
            if ($D<10) {$D1="0".$D};
            $HourList{$D} = $D1;
        }
        $Param{DayStrg} = $Self->{LayoutObject}->OptionStrgHashRef(
            Data => \%DayList,
            Name => 'Days',
            SelectedID => $Self->{ConfigObject}->Get('Genetel::Search::AgeMax') 
|| '',
        );
        $Param{HourStrg} = $Self->{LayoutObject}->OptionStrgHashRef(
            Data => \%HourList,
            Name => 'Hours',
            SelectedID => 
$Self->{ConfigObject}->Get('Genetel::Search::LastModificationAge') || '',
        );


        # search user list
        my @UserList=$Self->{RapportObject}->GetCustomerList($Self);

        foreach my $Customer (@UserList) {
            $Self->{LayoutObject}->Block(
                Name => 'Customer',
                Data => {
                    Param => $Customer->{Frontend},
                    Field => $Self->{LayoutObject}->OptionStrgHashRef(
                        Data => $Customer->{Data},
                        Name => $Customer->{Name},
                        SelectedID => $Customer->{SelectedID} || '',
                        Multiple => $Customer->{Multiple} || 0,
                        Size => $Customer->{Size} || '',
                    ),
                },
            );
        }
        
        $Output .= $Self->{LayoutObject}->Output(
            TemplateFile => 'GenetelSearch',
            Data => { %Param, },
        );
        $Output .= $Self->{LayoutObject}->Footer();
        return $Output;
    }
}

# --
# SUB TicketSearch
# --
sub TicketSearchAge {
        my $Self = shift;
        my %Param = @_;
        my @Queues = $Self->{RapportObject}->GetValidQueues($Self);
        $Self->{LogObject}->Log(Priority => 'notice', Message => "GENETEL 
TicketSearch - Params: $Param{'Days'}, $Param{'Hours'} - @Queues");
        my %TicketSearch=(
                Result => 'ARRAY',
                UserID => 1,
                TicketCreateTimeNewerMinutes => $Param{'Days'} * 1440,
                Queues => [EMAIL PROTECTED],
                StateType => 'Open',
        );
        
        my @TicketIDs = $Self->{TicketObject}->TicketSearch(
                %TicketSearch,
        );
    
        return @TicketIDs;
}

sub TicketSearchCustomer {
        my $Self = shift;
        my %Param = @_;
        my @Queues = $Self->{RapportObject}->GetValidQueues($Self);
        $Self->{LogObject}->Log(Priority => 'notice', Message => "GENETEL 
TicketSearch - Params: $Param{'Days'}, $Param{'Hours'} - @Queues");
        my %TicketSearch=(
                Result => 'ARRAY',
                UserID => 1,
                CustomerID => $Param{'Customer'},
                Queues => [EMAIL PROTECTED],
                StateType => 'Open',
        );
        
        my @TicketIDs = $Self->{TicketObject}->TicketSearch(
                %TicketSearch,
        );
    
        return @TicketIDs;
}

# --
1;
begin:vcard
fn:Alexandre Fourey
n:Fourey;Alexandre
email;internet:[EMAIL PROTECTED]
title:Conseil en informatique
tel;cell:+33(0)667675012
note:www.fourey.fr
x-mozilla-html:FALSE
version:2.1
end:vcard

_______________________________________________
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