From 3c8607b0e17a1191045fab694ed4e090934f183a Mon Sep 17 00:00:00 2001 From: Henri-Damien LAURENT Date: Wed, 7 Oct 2009 22:55:46 +0200 Subject: [PATCH] MT 1716 : Followup : search by initial was broken Signed-off-by: Henri-Damien LAURENT --- members/member.pl | 14 ++++++++------ members/members-home.pl | 3 ++- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/members/member.pl b/members/member.pl index e7f297b9e1..bdb5aad837 100755 --- a/members/member.pl +++ b/members/member.pl @@ -55,8 +55,13 @@ if($quicksearch){ } my $theme = $input->param('theme') || "default"; +my $patron = $input->Vars; +foreach (keys %$patron){ + delete $$patron{$_} unless($$patron{$_}); +} + my @categories=C4::Category->all; -my $branches=GetBranchesLoop(); +my $branches=(defined $$patron{branchcode}?GetBranchesLoop($$patron{branchcode}):GetBranchesLoop()); my %categories_dislay; @@ -82,16 +87,13 @@ $member =~ s/\*/%/g; my ($count,$results); -my $patron = $input->Vars; -foreach (keys %$patron){ - delete $$patron{$_} unless($$patron{$_}); -} 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{firstname}.="\%" if ($$patron{firstname}); +$$patron{surname}.="\%" if ($$patron{surname}); my @searchpatron; push @searchpatron, $member if ($member); @@ -99,7 +101,7 @@ 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"] ) 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); } diff --git a/members/members-home.pl b/members/members-home.pl index 6206f2cf35..e641feb78d 100755 --- a/members/members-home.pl +++ b/members/members-home.pl @@ -28,6 +28,7 @@ use C4::Category; my $query = new CGI; my $quicksearch = $query->param('quicksearch'); +my $branch = $query->param('branchcode'); my ($template, $loggedinuser, $cookie); my $template_name; @@ -52,7 +53,7 @@ if($quicksearch){ } my @categories=C4::Category->all; $template->param( - branchloop=>GetBranchesLoop(), + branchloop=>(defined $branch?GetBranchesLoop($branch):GetBranchesLoop()), categoryloop=>\@categories, ); $template->param( -- 2.39.5