-my $branches = GetBranches();
-my @branchloop = map { code => $_,
- name => $branches->{$_}->{'branchname'} },
- sort { $branches->{$a}->{branchname} cmp $branches->{$b}->{branchname} }
- keys %$branches;
-my (@branchfromloop, @cost, @errors);
+my @branchloop = map { code => $_->branchcode, name => $_->branchname }, Koha::Libraries->search({}, { order_by => 'branchname' })->as_list;
+my (@branchfromloop, @errors);