Bug 4117 Fix system error in routing slip recepients popup
authorColin Campbell <colin.campbell@ptfs-europe.com>
Fri, 5 Feb 2010 13:08:04 +0000 (13:08 +0000)
committerGalen Charlton <gmcharlt@gmail.com>
Fri, 5 Feb 2010 13:31:39 +0000 (08:31 -0500)
order_by parameter should be an arrayref of hashrefs
Have made order surname, firstname asc (see bug 4067)
do not generate logged warnings by manipulating undef

Signed-off-by: Galen Charlton <gmcharlt@gmail.com>
serials/member-search.pl

index 6009db4..549067a 100755 (executable)
@@ -71,8 +71,10 @@ if (C4::Context->preference("AddPatronLists")=~/code/){
 my $member=$cgi->param('member');
 my $orderby=$cgi->param('orderby');
 $orderby = "surname,firstname" unless $orderby;
-$member =~ s/,//g;   #remove any commas from search string
-$member =~ s/\*/%/g;
+if (defined $member) {
+    $member =~ s/,//g;   #remove any commas from search string
+    $member =~ s/\*/%/g;
+}
 
 my ($count,$results);
 
@@ -86,13 +88,21 @@ $$patron{surname}.="\%" if ($$patron{surname});
 
 my @searchpatron;
 push @searchpatron, $member if ($member);
-push @searchpatron, $patron if (keys %$patron);
-my $from= ($startfrom-1)*$resultsperpage;
-my $to=$from+$resultsperpage;
- #($results)=Search(\@searchpatron,{surname=>1,firstname=>1},[$from,$to],undef,["firstname","surname","email","othernames"]  ) if (@searchpatron);
- ($results)=Search(\@searchpatron,{surname=>1,firstname=>1},undef,undef,["firstname","surname","email","othernames","cardnumber"],"start_with"  ) if (@searchpatron);
-if ($results){
-       $count =scalar(@$results);
+push @searchpatron, $patron if ( keys %$patron );
+my $from = ( $startfrom - 1 ) * $resultsperpage;
+my $to   = $from + $resultsperpage;
+if (@searchpatron) {
+    ($results) = Search(
+        \@searchpatron,
+        [ { surname => 0 }, { firstname => 0 } ],
+        undef,
+        undef,
+        [ "firstname", "surname", "email", "othernames", "cardnumber" ],
+        "start_with"
+    );
+}
+if ($results) {
+    $count = scalar(@$results);
 }
 my @resultsdata;
 $to=($count>$to?$to:$count);