X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=members%2Fmember.pl;h=d25dba9d181fd0763b8f5d03b78868f374618834;hb=acbfe26c9ef6e40f4509babd6e1d39e1762e13e3;hp=2be45bc79bbef904f413ce703227ab1fb4ce5867;hpb=97446f86ced2c2d6d4d7a11b97ed81a5a0a25d95;p=koha.git diff --git a/members/member.pl b/members/member.pl index 2be45bc79b..d25dba9d18 100755 --- a/members/member.pl +++ b/members/member.pl @@ -58,7 +58,8 @@ my $branches = GetBranches; my @branchloop; foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %$branches) { - my $selected = 1 if $branches->{$_}->{branchcode} eq $$patron{branchcode}; + my $selected; + $selected = 1 if $branches->{$_}->{branchcode} eq $$patron{branchcode}; my %row = ( value => $_, selected => $selected, branchname => $branches->{$_}->{branchname}, @@ -75,10 +76,11 @@ foreach my $category (@categories){ }; $categories_dislay{$$category{categorycode}} = $hash; } +my $AddPatronLists = C4::Context->preference("AddPatronLists") || ''; $template->param( - "AddPatronLists_".C4::Context->preference("AddPatronLists")=> "1", + "AddPatronLists_$AddPatronLists" => "1", ); -if (C4::Context->preference("AddPatronLists")=~/code/){ +if ($AddPatronLists=~/code/){ $categories[0]->{'first'}=1; } @@ -93,20 +95,21 @@ else { @orderby = ({surname=>0},{firstname=>0}); } +my $searchfields = $input->param('searchfields'); +my @searchfields = $searchfields ? split( ',', $searchfields ) : ( "firstname", "surname", "othernames", "cardnumber", "userid", "email" ); + $member =~ s/,//g; #remove any commas from search string $member =~ s/\*/%/g; -my ($count,$results); - -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); -my $search_scope = ( $quicksearch ? "field_start_with" : "start_with" ); -($results) = Search( \@searchpatron, \@orderby, undef, undef, [ "firstname", "surname", "othernames", "cardnumber", "userid" ], $search_scope ) if (@searchpatron); +my ($count,$results); +if ($member || keys %$patron) { + #($results)=Search($member || $patron,{surname=>1,firstname=>1},[$from,$to],undef,["firstname","surname","email","othernames"] ); + my $search_scope = ( $quicksearch ? "field_start_with" : "start_with" ); + ($results) = Search( $member || $patron, \@orderby, undef, undef, \@searchfields, $search_scope ); +} if ($results) { for my $field ('categorycode','branchcode'){ @@ -115,6 +118,12 @@ if ($results) { } $count = scalar(@$results); } + +if($count == 1){ + print $input->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=" . @$results[0]->{borrowernumber}); + exit; +} + my @resultsdata; $to=($count>$to?$to:$count); my $index=$from; @@ -126,12 +135,13 @@ foreach my $borrower(@$results[$from..$to-1]){ my %row = ( count => $index++, - %$borrower, - %{$categories_dislay{$$borrower{categorycode}}}, + %$borrower, + (defined $categories_dislay{ $borrower->{categorycode} }? %{ $categories_dislay{ $borrower->{categorycode} } }:()), overdues => $od, issues => $issue, odissue => "$od/$issue", fines => sprintf("%.2f",$fines), + branchname => $branches->{$borrower->{branchcode}}->{branchname}, ); push(@resultsdata, \%row); }