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
---
 serials/member-search.pl |   28 +++++++++++++++++++---------
 1 files changed, 19 insertions(+), 9 deletions(-)

diff --git a/serials/member-search.pl b/serials/member-search.pl
index 6009db4..549067a 100755
--- a/serials/member-search.pl
+++ b/serials/member-search.pl
@@ -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);
-- 
1.6.6

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches

Reply via email to