X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=serials%2Fmember-search.pl;h=ecbb94f9c07f7184468816fe50e004b83db5da27;hb=ed63c139576138e870211dddf327227f2b824fac;hp=6009db45da8d680dbb5eabbc664c874175228f43;hpb=f36c042b80f053b7f75dfc1aff12a312e5a59134;p=koha_fer diff --git a/serials/member-search.pl b/serials/member-search.pl index 6009db45da..ecbb94f9c0 100755 --- a/serials/member-search.pl +++ b/serials/member-search.pl @@ -1,5 +1,7 @@ #!/usr/bin/perl +# Parts copyright Catalyst IT 2010 +# # This file is part of Koha. # # Koha is free software; you can redistribute it and/or modify it under the @@ -11,9 +13,9 @@ # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR # A PARTICULAR PURPOSE. See the GNU General Public License for more details. # -# You should have received a copy of the GNU General Public License along with -# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place, -# Suite 330, Boston, MA 02111-1307 USA +# You should have received a copy of the GNU General Public License along +# with Koha; if not, write to the Free Software Foundation, Inc., +# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. =head1 member-search.pl @@ -43,6 +45,8 @@ foreach (keys %$patron){ my @categories=C4::Category->all; my $branches=(defined $$patron{branchcode}?GetBranchesLoop($$patron{branchcode}):GetBranchesLoop()); +my $subscriptionid = $cgi->param('subscriptionid'); +my $searchstring = $cgi->param('member'); my %categories_dislay; my ($template, $loggedinuser, $cookie); @@ -51,7 +55,7 @@ my ($template, $loggedinuser, $cookie); query => $cgi, type => "intranet", authnotrequired => 0, - flagsrequired => {borrowers => 1}, + flagsrequired => { serials => 'routing' }, }); foreach my $category (@categories){ @@ -71,14 +75,16 @@ 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); if (C4::Context->preference("IndependantBranches")){ if (C4::Context->userenv && C4::Context->userenv->{flags} % 2 !=1 && C4::Context->userenv->{'branch'}){ - $$patron{branchcode}=C4::Context->userenv->{'branch'} unless (C4::Context->userenv->{'branch'} eq "insecure"); + $$patron{branchcode}=C4::Context->userenv->{'branch'}; } } $$patron{firstname}.="\%" if ($$patron{firstname}); @@ -86,30 +92,40 @@ $$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); my $index=$from; foreach my $borrower(@$results[$from..$to-1]){ - #find out stats - - $$borrower{'dateexpiry'}= C4::Dates->new($$borrower{'dateexpiry'},'iso')->output('syspref'); - - my %row = ( - count => $index++, - %$borrower, - %{$categories_dislay{$$borrower{categorycode}}}, - ); - push(@resultsdata, \%row); + # find out stats + $borrower->{'dateexpiry'}= C4::Dates->new($borrower->{'dateexpiry'},'iso')->output('syspref'); + if ($categories_dislay{$borrower->{'categorycode'}}){ + my %row = ( + count => $index++, + %$borrower, + %{$categories_dislay{$$borrower{categorycode}}}, + ); + push(@resultsdata, \%row); + } + else { + warn $borrower->{'cardnumber'} ." has a bad category code of " . $borrower->{'categorycode'} ."\n"; + } } - if ($$patron{branchcode}){ foreach my $branch (grep{$_->{value} eq $$patron{branchcode}}@$branches){ $$branch{selected}=1;