diff options
author | ivan <ivan> | 2010-07-23 22:50:59 +0000 |
---|---|---|
committer | ivan <ivan> | 2010-07-23 22:50:59 +0000 |
commit | 5ef991c5001d0a9413d99cc76f152f3a7b71459b (patch) | |
tree | ecdae79c4117110c63f7d82f0d7fa239e777675b /rt | |
parent | c6a3eafdce6e88b4f33a37a824331d5d9be8d9bd (diff) |
cleaner customer number searching, RT#8784
Diffstat (limited to 'rt')
-rw-r--r-- | rt/lib/RT/Tickets_Overlay.pm | 66 |
1 files changed, 9 insertions, 57 deletions
diff --git a/rt/lib/RT/Tickets_Overlay.pm b/rt/lib/RT/Tickets_Overlay.pm index 8faf3f0..f2949ed 100644 --- a/rt/lib/RT/Tickets_Overlay.pm +++ b/rt/lib/RT/Tickets_Overlay.pm @@ -1724,7 +1724,6 @@ sub OrderByCols { next; } if ( $row->{FIELD} !~ /\./ ) { - my $meta = $self->FIELDS->{ $row->{FIELD} }; unless ( $meta ) { push @res, $row; @@ -1855,23 +1854,23 @@ sub OrderByCols { VALUE => 'freeside://freeside/cust_main/', ); + #if there was a Links.RemoteTarget int, this bs wouldn't be necessary + my $custnum_sql = "CAST(SUBSTR($linkalias.Target,31) AS INTEGER)"; + if ( $subkey eq 'Number' ) { push @res, { %$row, - ALIAS => $linkalias, - FIELD => "CAST(SUBSTR(Target,31) AS INTEGER)", - #ORDER => ($row->{ORDER} || 'ASC') + ALIAS => '', + FIELD => $custnum_sql, }; } elsif ( $subkey eq 'Name' ) { my $custalias = $self->Join( - TYPE => 'LEFT', - #ALIAS1 => $linkalias, - #FIELD1 => 'CAST(SUBSTR(Target,31) AS INTEGER)', - EXPRESSION => "CAST(SUBSTR($linkalias.Target,31) AS INTEGER)", - TABLE2 => 'cust_main', - FIELD2 => 'custnum', + TYPE => 'LEFT', + EXPRESSION => $custnum_sql, + TABLE2 => 'cust_main', + FIELD2 => 'custnum', ); @@ -1894,53 +1893,6 @@ sub OrderByCols { # }}} -#this duplicates/ovverrides the DBIx::SearchBuilder version.. -# we need to fix the "handle FUNCTION(FIELD)" stuff and this is much easier -# than patching SB -# but does this have other terrible ramifications? maybe a flag to trigger -# this specific case? -sub _OrderClause { - my $self = shift; - - return '' unless $self->{'order_by'}; - - my $clause = ''; - foreach my $row ( @{$self->{'order_by'}} ) { - - my %rowhash = ( ALIAS => 'main', - FIELD => undef, - ORDER => 'ASC', - %$row - ); - if ($rowhash{'ORDER'} && $rowhash{'ORDER'} =~ /^des/i) { - $rowhash{'ORDER'} = "DESC"; - } - else { - $rowhash{'ORDER'} = "ASC"; - } - $rowhash{'ALIAS'} = 'main' unless defined $rowhash{'ALIAS'}; - - if ( defined $rowhash{'ALIAS'} and - $rowhash{'FIELD'} and - $rowhash{'ORDER'} ) { - - if ( length $rowhash{'ALIAS'} && $rowhash{'FIELD'} =~ /^((\w+\()+)(.*\)+)$/ ) { - # handle 'FUNCTION(FIELD)' formatted fields - $rowhash{'FIELD'} = $1. $rowhash{'ALIAS'}. '.'. $3; - $rowhash{'ALIAS'} = ''; - } - - $clause .= ($clause ? ", " : " "); - $clause .= $rowhash{'ALIAS'} . "." if length $rowhash{'ALIAS'}; - $clause .= $rowhash{'FIELD'} . " "; - $clause .= $rowhash{'ORDER'}; - } - } - $clause = " ORDER BY$clause " if $clause; - - return $clause; -} - # {{{ Limit the result set based on content # {{{ sub Limit |