add ticket_system-priority_reverse config
authorivan <ivan>
Tue, 9 Oct 2007 04:48:25 +0000 (04:48 +0000)
committerivan <ivan>
Tue, 9 Oct 2007 04:48:25 +0000 (04:48 +0000)
FS/FS/Conf.pm
FS/FS/TicketSystem/RT_External.pm

index adf7413..5fe28b8 100644 (file)
@@ -1652,6 +1652,13 @@ httemplate/docs/config.html
   },
 
   {
   },
 
   {
+    'key'         => 'ticket_system-priority_reverse',
+    'section'     => '',
+    'description' => 'Enable this to consider lower numbered priorities more important.  A bad habit we picked up somewhere.  You probably want to avoid it and use the default.',
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'ticket_system-custom_priority_field',
     'section'     => '',
     'description' => 'Custom field from the ticketing system to use as a custom priority classification.',
     'key'         => 'ticket_system-custom_priority_field',
     'section'     => '',
     'description' => 'Custom field from the ticketing system to use as a custom priority classification.',
index cd6834c..0b9a98e 100644 (file)
@@ -2,6 +2,7 @@ package FS::TicketSystem::RT_External;
 
 use strict;
 use vars qw( $DEBUG $me $conf $dbh $default_queueid $external_url
 
 use strict;
 use vars qw( $DEBUG $me $conf $dbh $default_queueid $external_url
+             $priority_reverse
              $priority_field $priority_field_queue $field
           );
 use URI::Escape;
              $priority_field $priority_field_queue $field
           );
 use URI::Escape;
@@ -15,6 +16,7 @@ $DEBUG = 0;
 FS::UID->install_callback( sub { 
   $conf = new FS::Conf;
   $default_queueid = $conf->config('ticket_system-default_queueid');
 FS::UID->install_callback( sub { 
   $conf = new FS::Conf;
   $default_queueid = $conf->config('ticket_system-default_queueid');
+  $priority_reverse = $conf->exists('ticket_system-priority_reverse');
   $priority_field =
     $conf->config('ticket_system-custom_priority_field');
   if ( $priority_field ) {
   $priority_field =
     $conf->config('ticket_system-custom_priority_field');
   if ( $priority_field ) {
@@ -75,7 +77,11 @@ sub customer_tickets {
           "position(tickets.status in 'newopenstalledresolvedrejecteddeleted')".
          " AS svalue " .
           ( length($priority) ? ", objectcustomfieldvalues.content" : '' ).
           "position(tickets.status in 'newopenstalledresolvedrejecteddeleted')".
          " AS svalue " .
           ( length($priority) ? ", objectcustomfieldvalues.content" : '' ).
-          " $from_sql ORDER BY svalue, priority DESC, id DESC LIMIT $limit";
+          " $from_sql ".
+          " ORDER BY svalue, ".
+          "          priority ". ( $priority_reverse ? 'ASC' : 'DESC' ). ", ".
+          "          id DESC ".
+          " LIMIT $limit";
   warn "$me $sql (@param)" if $DEBUG;
   my $sth = $dbh->prepare($sql) or die $dbh->errstr. "preparing $sql";
   $sth->execute(@param)         or die $sth->errstr. "executing $sql";
   warn "$me $sql (@param)" if $DEBUG;
   my $sth = $dbh->prepare($sql) or die $dbh->errstr. "preparing $sql";
   $sth->execute(@param)         or die $sth->errstr. "executing $sql";