
Hello, we are using OTRS and we talk about closed tickets each week. This helps us track the tickets and spread knowledge. There was no way in OTRS "to search for all Tickets closed in the last week". I modified OTRS 2.2.0 rc1 to enable such a seach. Attached you find the patch against OTRS 2.2.0 rc1 and a screenshot of the search integrated into the search screen.. It would be great if this feature would be picked upo by the main line OTRS distribution (so I do not have to patch it in after each update :) Regards, Robert Heinzmann --- Kernel/Output/HTML/Standard/AgentTicketSearch.dtl.ORG 2007-06-19 06:29:44.000000000 +0200 +++ Kernel/Output/HTML/Standard/AgentTicketSearch.dtl 2007-07-26 14:21:05.000000000 +0200 @@ -234,6 +234,22 @@ $Text{"Ticket created between"} $Data{"TicketCreateTimeStart"} $Text{"and"} $Data{"TicketCreateTimeStop"} </td> </tr> + <tr> + <td colspan="2" class="contenthead">$Text{"Close Times"}</td> + </tr> + <tr> + <td colspan="2" class="contentbody"> + + $Text{"No close time settings."} + </td> + </tr> + <tr> + <td colspan="2" class="contentbody"> + + $Text{"Ticket closed"} $Data{"TicketCloseTimePointStart"} $Data{"TicketCloseTimePoint"} $Data{"TicketCloseTimePointFormat"} + </td> + </tr> + <tr> <td class="contenthead">$Text{"Result Form"}</td> <td class="contenthead">$Text{"Save Search-Profile as Template?"}</td> --- Kernel/System/Ticket.pm.ORG 2007-07-26 13:30:22.000000000 +0200 +++ Kernel/System/Ticket.pm 2007-07-26 14:09:01.000000000 +0200 @@ -3495,6 +3495,21 @@ $SQLExt .= " AND st.create_time >= '".$Self->{DBObject}->Quote($Param{TicketCreateTimeNewerDate})."'"; } } + + # get tickets closed since TIMESPEC seconds (seconds sind 70s) + if ($Param{TicketCloseTimeNewerMinutes}) { + + my $Time = $Self->{TimeObject}->SystemTime()-($Param{TicketCloseTimeNewerMinutes}*60); + my $TimeStamp = $Self->{TimeObject}->SystemTime2TimeStamp( + SystemTime => $Time, + ); + $Param{TicketCloseTimeNewerDate}=$TimeStamp; + $Self->{LogObject}->Log( + Priority => 'notice', + Message => "Search for ticket closed older than '$Param{TicketCloseTimeNewerMinutes}' minutes (timestamp: $Param{TicketCloseTimeNewerDate})!", + ); + } + # get tickets closed older then xxxx-xx-xx xx:xx date if ($Param{TicketCloseTimeOlderDate}) { # check time format --- Kernel/Language/de.pm.ORG 2007-06-19 06:29:44.000000000 +0200 +++ Kernel/Language/de.pm 2007-07-26 17:43:49.000000000 +0200 @@ -639,6 +639,9 @@ 'Ticket Lock' => 'Ticket sperren', 'TicketFreeFields' => 'TicketFreiFelder', 'Create Times' => 'Erstell-Zeiten', + 'Close Times' => 'Schließ-Zeiten', + 'No close time settings.' => 'Keine Schließ-Zeiten', + 'Ticket closed' => 'Ticket geschlossen', 'No create time settings.' => 'Keine Erstell-Zeiten', 'Ticket created' => 'Ticket erstellt', 'Ticket created between' => 'Ticket erstellt zwischen', --- Kernel/Modules/AgentTicketSearch.pm.ORG 2007-06-19 06:29:44.000000000 +0200 +++ Kernel/Modules/AgentTicketSearch.pm 2007-07-26 14:21:33.000000000 +0200 @@ -114,7 +114,7 @@ # get search string params (get submitted params) else { foreach (qw(TicketNumber From To Cc Subject Body CustomerID CustomerUserLogin - Agent ResultForm TimeSearchType + Agent ResultForm TimeSearchType TimeCloseSearchType TicketFreeTime1 TicketFreeTime1Start TicketFreeTime1StartDay TicketFreeTime1StartMonth TicketFreeTime1StartYear @@ -161,6 +161,8 @@ TicketCreateTimeStartYear TicketCreateTimeStop TicketCreateTimeStopDay TicketCreateTimeStopMonth TicketCreateTimeStopYear + TicketCloseTimePointFormat TicketCloseTimePoint + TicketCloseTimePointStart )) { # get search string params (get submitted params) $GetParam{$_} = $Self->{ParamObject}->GetParam(Param => $_); @@ -200,6 +202,13 @@ elsif ($GetParam{TimeSearchType} eq 'TimeSlot') { $GetParam{'TimeSearchType::TimeSlot'} = 'checked'; } + # get time option + if (!$GetParam{TimeCloseSearchType}) { + $GetParam{'TimeCloseSearchType::None'} = 'checked'; + } + elsif ($GetParam{TimeCloseSearchType} eq 'TimePoint') { + $GetParam{'TimeCloseSearchType::TimePoint'} = 'checked'; + } # set result form env if (!$GetParam{ResultForm}) { $GetParam{ResultForm} = ''; @@ -312,6 +321,65 @@ } } } + + # get time settings + if (!$GetParam{TimeCloseSearchType}) { + # do noting ont time stuff + } +# TBD later (anyone?) +# elsif ($GetParam{TimeCloseSearchType} eq 'TimeSlot') { +# foreach (qw(Month Day)) { +# $GetParam{"TicketCreateTimeStart$_"} = sprintf("%02d", $GetParam{"TicketCreateTimeStart$_"}); +# } +# foreach (qw(Month Day)) { +# $GetParam{"TicketCreateTimeStop$_"} = sprintf("%02d", $GetParam{"TicketCreateTimeStop$_"}); +# } +# if ($GetParam{TicketCreateTimeStartDay} && +# $GetParam{TicketCreateTimeStartMonth} && +# $GetParam{TicketCreateTimeStartYear} +# ) { +# $GetParam{TicketCreateTimeNewerDate} = $GetParam{TicketCreateTimeStartYear}. +# '-'.$GetParam{TicketCreateTimeStartMonth}. +# '-'.$GetParam{TicketCreateTimeStartDay}. +# ' 00:00:01'; +# } +# if ($GetParam{TicketCreateTimeStopDay} && +# $GetParam{TicketCreateTimeStopMonth} && +# $GetParam{TicketCreateTimeStopYear} +# ) { +# $GetParam{TicketCreateTimeOlderDate} = $GetParam{TicketCreateTimeStopYear}. +# '-'.$GetParam{TicketCreateTimeStopMonth}. +# '-'.$GetParam{TicketCreateTimeStopDay}. +# ' 23:59:59'; +# } +# } + elsif ($GetParam{TimeCloseSearchType} eq 'TimePoint') { + if ($GetParam{TicketCloseTimePoint} && + $GetParam{TicketCloseTimePointStart} && + $GetParam{TicketCloseTimePointFormat} + ) { + my $Time = 0; + if ($GetParam{TicketCloseTimePointFormat} eq 'minute') { + $Time = $GetParam{TicketCloseTimePoint}; + } + elsif ($GetParam{TicketCloseTimePointFormat} eq 'hour') { + $Time = $GetParam{TicketCloseTimePoint} * 60; + } + elsif ($GetParam{TicketCloseTimePointFormat} eq 'day') { + $Time = $GetParam{TicketCloseTimePoint} * 60 * 24; + } + elsif ($GetParam{TicketCloseTimePointFormat} eq 'week') { + $Time = $GetParam{TicketCloseTimePoint} * 60 * 24 * 7; + } + elsif ($GetParam{TicketCloseTimePointFormat} eq 'month') { + $Time = $GetParam{TicketCloseTimePoint} * 60 * 24 * 30; + } + elsif ($GetParam{TicketCloseTimePointFormat} eq 'year') { + $Time = $GetParam{TicketCloseTimePoint} * 60 * 24 * 365; + } + $GetParam{TicketCloseTimeNewerMinutes} = $Time; + } + } # free time foreach (1..6) { if (!$GetParam{'TicketFreeTime'.$_}) { @@ -976,6 +1044,91 @@ Name => 'TicketCreateTimePointFormat', SelectedID => $Param{TicketCreateTimePointFormat}, ); + $Param{'TicketCloseTimePoint'} = $Self->{LayoutObject}->OptionStrgHashRef( + Data => { + 1 => ' 1', + 2 => ' 2', + 3 => ' 3', + 4 => ' 4', + 5 => ' 5', + 6 => ' 6', + 7 => ' 7', + 8 => ' 8', + 9 => ' 9', + 10 => '10', + 11 => '11', + 12 => '12', + 13 => '13', + 14 => '14', + 15 => '15', + 16 => '16', + 17 => '17', + 18 => '18', + 19 => '19', + 20 => '20', + 21 => '21', + 22 => '22', + 23 => '23', + 24 => '24', + 25 => '25', + 26 => '26', + 27 => '27', + 28 => '28', + 29 => '29', + 30 => '30', + 31 => '31', + 32 => '32', + 33 => '33', + 34 => '34', + 35 => '35', + 36 => '36', + 37 => '37', + 38 => '38', + 39 => '39', + 40 => '40', + 41 => '41', + 42 => '42', + 43 => '43', + 44 => '44', + 45 => '45', + 46 => '46', + 47 => '47', + 48 => '48', + 49 => '49', + 50 => '50', + 51 => '51', + 52 => '52', + 53 => '53', + 54 => '54', + 55 => '55', + 56 => '56', + 57 => '57', + 58 => '58', + 59 => '59', + }, + Name => 'TicketCloseTimePoint', + SelectedID => $Param{TicketCloseTimePoint}, + ); + $Param{'TicketCloseTimePointStart'} = $Self->{LayoutObject}->OptionStrgHashRef( + Data => { + 'Last' => 'last', +# 'Before' => 'before', + }, + Name => 'TicketCloseTimePointStart', + SelectedID => $Param{TicketCloseTimePointStart} || 'Last', + ); + $Param{'TicketCloseTimePointFormat'} = $Self->{LayoutObject}->OptionStrgHashRef( + Data => { + minute => 'minute(s)', + hour => 'hour(s)', + day => 'day(s)', + week => 'week(s)', + month => 'month(s)', + year => 'year(s)', + }, + Name => 'TicketCloseTimePointFormat', + SelectedID => $Param{TicketCloseTimePointFormat}, + ); $Param{TicketCreateTimeStart} = $Self->{LayoutObject}->BuildDateSelection( %Param, Prefix => 'TicketCreateTimeStart',