Enable TicketCloseTimeNewerMinutes Search

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',

Hi, Checked on Google and OTRS mailing list archives for an answer to this question but can't find one. This may have something to do with development. I'm currently on the process of migrating to OTRS for a specific platform and in this way I was asked to restore back on OTRS all of our old Double Choco Latte tickets data so we wil have all historical tickets accessible through OTRS. For the moment, I run into creating data in OTRS by sending custom mails containing old data and so let it create all necessaries entries by itself, so I'm using a lot all of these useful X-OTRS-* Headers BUT I wonder : - is there any "hidden"/undocumented headers like X-OTRS-TicketID or X-OTRS-EmailDate ? It would help a lot because we need to keep Ticket Numbers the same between old and new ticketing system and for dates it would be better if we can keep original creation/modification/resolution dates from original emails. - does anyone see a better way to integrate back all of these datas into OTRS ? Thanks by advance for your answers. Best regards, Laurent

Laurent Minost schrieb:
Hi,
Checked on Google and OTRS mailing list archives for an answer to this question but can't find one. This may have something to do with development. I'm currently on the process of migrating to OTRS for a specific platform and in this way I was asked to restore back on OTRS all of our old Double Choco Latte tickets data so we wil have all historical tickets accessible through OTRS.
For the moment, I run into creating data in OTRS by sending custom mails containing old data and so let it create all necessaries entries by itself, so I'm using a lot all of these useful X-OTRS-* Headers BUT I wonder :
- is there any "hidden"/undocumented headers like X-OTRS-TicketID or X-OTRS-EmailDate ? It would help a lot because we need to keep Ticket Numbers the same between old and new ticketing system and for dates it would be better if we can keep original creation/modification/resolution dates from original emails.
No, there isn't. And it's kind of intentionally this way. Passing a ticket number is dangerous, because the very same number may exist already. and where you expect a new ticket to be created the mail would just be attached (best case) or you would end up with two tickets having the same number (worst case). Passing a date would make it too easy to spoof mails and destroy the reliably of the record. I realize neither risk really exists in your case, but for the general case we need to be careful with such features.
- does anyone see a better way to integrate back all of these datas into OTRS ?
You could write a custom postmaster filter doing just what you descibribed and pipe your mails into it. In a custom filter you're not restricted to the X-OTRS headers, but can use the OTRS internals to accomplish what you're looking for. hth, BB

Hi Robert, Robert Heinzmann schrieb:
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 :)
Nice feature. Could you do us a favour and submit the patch in bugzilla? http://bugs.otrs.org Makes it easier for us to follow up with it. Thanks, BB
participants (3)
-
Bodo Bauer
-
Laurent Minost
-
Robert Heinzmann