-$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":"contain");
- ($results)=Search(\@searchpatron,\@orderby,undef,undef,["firstname","surname","email","othernames","cardnumber","userid"],$search_scope ) if (@searchpatron);
-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
- my ($od,$issue,$fines)=GetMemberIssuesAndFines($$borrower{'borrowernumber'});
-
- $$borrower{'dateexpiry'}= C4::Dates->new($$borrower{'dateexpiry'},'iso')->output('syspref');
-
- my %row = (
- count => $index++,
- %$borrower,
- %{$categories_dislay{$$borrower{categorycode}}},
- overdues => $od,
- issues => $issue,
- odissue => "$od/$issue",
- fines => sprintf("%.2f",$fines),
- );
- push(@resultsdata, \%row);
+my $branches = C4::Branch::GetBranches;
+my @branches_loop;
+if ( C4::Branch::onlymine ) {
+ my $userenv = C4::Context->userenv;
+ my $branch = C4::Branch::GetBranchDetail( $userenv->{'branch'} );
+ push @branches_loop, {
+ value => $branch->{branchcode},
+ branchcode => $branch->{branchcode},
+ branchname => $branch->{branchname},
+ selected => 1
+ }
+} else {
+ foreach ( sort { lc($branches->{$a}->{branchname}) cmp lc($branches->{$b}->{branchname}) } keys %$branches ) {
+ my $selected = 0;
+ $selected = 1 if($patron->{branchcode} and $patron->{branchcode} eq $_);
+ push @branches_loop, {
+ value => $_,
+ branchcode => $_,
+ branchname => $branches->{$_}->{branchname},
+ selected => $selected
+ };
+ }