-if($quicksearch){
-($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "members/member-quicksearch.tmpl",
- query => $query,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {borrowers => 1},
- debug => 1,
- });
-} else {
-($template, $loggedinuser, $cookie)
- = get_template_and_user({template_name => "members/members-home.tmpl",
- query => $query,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {borrowers => 1},
- debug => 1,
- });
+$branch = q{} unless defined $branch;
+
+my ($template, $loggedinuser, $cookie)
+ = get_template_and_user({template_name => "members/member.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => {borrowers => 1},
+ debug => 1,
+ });
+
+my $branches = GetBranches;
+my @branchloop;
+foreach (sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} } keys %{$branches}) {
+ push @branchloop, {
+ value => $_,
+ selected => ($branches->{$_}->{branchcode} eq $branch),
+ branchname => $branches->{$_}->{branchname},
+ };
+}
+
+my @categories;
+my $no_categories;
+my $no_add = 0;
+if(scalar(@branchloop) < 1){
+ $no_add = 1;
+ $template->param(no_branches => 1);
+}
+else {
+ $template->param(branchloop=>\@branchloop);
+}
+
+@categories=C4::Category->all;
+if(scalar(@categories) < 1){
+ $no_categories = 1;
+}
+
+if($no_categories && C4::Context->preference("AddPatronLists")=~/code/){
+ $no_add = 1;
+ $template->param(no_categories => 1);
+}
+else {
+ $template->param(categories=>\@categories);