ticket search for "this month", RT#11057
authormark <mark>
Fri, 28 Jan 2011 21:30:16 +0000 (21:30 +0000)
committermark <mark>
Fri, 28 Jan 2011 21:30:16 +0000 (21:30 +0000)
rt/FREESIDE_MODIFIED
rt/lib/RT/Date.pm
rt/lib/RT/Tickets_Overlay.pm

index 7730151..c6e4902 100644 (file)
@@ -15,16 +15,22 @@ lib/RT/Action.pm #create ticket on custom field change
 lib/RT/Condition.pm #create ticket on custom field change
 lib/RT/Scrip_Overlay.pm #create ticket on custom field change
 lib/RT/Action/CreateTickets.pm #create ticket on custom field change
+lib/RT/Action/EscalatePriority.pm #ticket escalation
+lib/RT/Action/EscalateQueue.pm #ticket escalation
+lib/RT/Action/SetPriority_Local.pm #ticket escalation
+lib/RT/CustomFieldValues/Queues.pm #ticket escalation
 lib/RT/Condition/CustomFieldChange.pm #create ticket on custom field change
 lib/RT/Interface/Web_Vendor.pm
  lib/RT/Interface/Web/Handler.pm #freeside comp_root for dashboard emails
  lib/RT/Record.pm #and customfield date patch
+lib/RT/SavedSearches_Local.pm #saved searches
 lib/RT/SearchBuilder.pm #need DBIx::SearchBuilder >= 1.36 for Pg 8.1+
 lib/RT/Transaction_Overlay.pm
-lib/RT/Tickets_Overlay.pm #customfield date patch #SearchCustomerFields
+lib/RT/Tickets_Overlay.pm #customfield date patch #SearchCustomerFields #this-month condition
  lib/RT/Ticket_Overlay.pm
  lib/RT/Users_Overlay.pm
  lib/RT/Groups_Overlay.pm
+lib/RT/Date.pm #this-month condition
 lib/RT/URI/freeside.pm
 lib/RT/URI/freeside/Internal.pm
 lib/RT/URI/freeside/XMLRPC.pm
@@ -57,6 +63,8 @@ share/html/Elements/EditCustomFieldDate #customfield date patch (NEW)
  share/html/Elements/PageLayout
  #html/Elements/QuickCreate
  share/html/Elements/RT__Ticket/ColumnMap
+share/html/Elements/RT__SavedSearch/ColumnMap #saved searches
+share/html/Elements/SavedSearches #saved searches
  share/html/Elements/ShowCustomFieldDate #customfield date patch (NEW)
  share/html/Elements/SelectDate
 share/html/Elements/ShowLink_Checklist
@@ -65,6 +73,7 @@ share/html/Elements/ShowLink_Checklist
  share/html/Elements/SelectCustomerAgent #SearchCustomerFields
  share/html/Elements/SelectCustomerClass #SearchCustomerFields
  share/html/Elements/SelectCustomerTag #SearchCustomerFields
+share/html/Prefs/SavedSearches.html #saved searches
  share/html/Search/Build.html
 share/html/Search/Results.tsv #content-type bug fix
  share/html/Search/Elements/BuildFormatString
@@ -79,7 +88,7 @@ share/html/Ticket/Elements/ShowMembers_Checklist
  share/html/Ticket/Elements/BulkLinks
  share/html/Ticket/Elements/ShowSummary
  share/html/Ticket/Elements/ShowTransactionAttachments
- share/html/Ticket/Elements/Tabs
+ share/html/Ticket/Elements/Tabs #saved searches
 share/html/Ticket/ModifyCustomers.html
  html/NoAuth/css/3.5-default/main.css
  html/NoAuth/css/3.5-default/misc.css
index fc4c43c..2c7a6b6 100644 (file)
@@ -273,6 +273,39 @@ sub SetToMidnight {
     return $self->Unix( $new );
 }
 
+=head2 SetToStart PERIOD[, Timezone => 'utc' ]
+
+Set to the beginning of the current PERIOD, which can be 
+"year", "month", "day", "hour", or "minute".
+
+=cut
+
+sub SetToStart {
+    my $self = shift;
+    my $p = uc(shift);
+    my %args = @_;
+    my $tz = $args{'Timezone'} || '';
+    my @localtime = $self->Localtime($tz);
+
+    # This is the cleanest way to implement it, I swear.
+    {
+        $localtime[0]=0;
+        last if ($p eq 'MINUTE');
+        $localtime[1]=0;
+        last if ($p eq 'HOUR');
+        $localtime[2]=0;
+        last if ($p eq 'DAY');
+        $localtime[3]=1;
+        last if ($p eq 'MONTH');
+        $localtime[4]=0;
+        last if ($p eq 'YEAR');
+        $RT::Logger->warning("Couldn't find start date of '$p'.");
+        return;
+    }
+    my $new = $self->Timelocal($tz, @localtime);
+    return $self->Unix($new);
+}
+
 =head2 Diff
 
 Takes either an C<RT::Date> object or the date in unixtime format as a string,
@@ -479,6 +512,25 @@ Adds 24 hours to the current time. Returns new unix time.
 
 sub AddDay { return $_[0]->AddSeconds($DAY) }
 
+=head2 AddMonth
+
+Adds one month to the current time. Returns new 
+unix time.
+
+=cut
+
+sub AddMonth {
+    require Time::ParseDate;
+    my $self = shift;
+    my $date = ( 
+        Time::ParseDate::parsedate(
+            '1 month',
+            NOW => $self->Unix
+        )
+    );
+    return $self->Unix($date);
+}
+
 =head2 Unix [unixtime]
 
 Optionally takes a date in unix seconds since the epoch format.
index 89d64c5..e3658fe 100644 (file)
@@ -539,11 +539,22 @@ sub _DateFieldLimit {
         # if we're specifying =, that means we want everything on a
         # particular single day.  in the database, we need to check for >
         # and < the edges of that day.
-
-        $date->SetToMidnight( Timezone => 'server' );
-        my $daystart = $date->ISO;
-        $date->AddDay;
-        my $dayend = $date->ISO;
+       
+        my ($daystart, $dayend);
+        if ( lc($value) eq 'this month' ) { 
+            # special case: > and < the edges of this month
+            $date->SetToNow;
+            $date->SetToStart('month');
+            $daystart = $date->ISO;
+            $date->AddMonth;
+            $dayend = $date->ISO;
+        }
+        else {
+            $date->SetToMidnight( Timezone => 'server' );
+            $daystart = $date->ISO;
+            $date->AddDay;
+            $dayend = $date->ISO;
+        }
 
         $sb->_OpenParen;