Bug 20504: Fix lang attribute in html tag on systempreferences page
[koha.git] / admin / transport-cost-matrix.pl
index 3197306..ea1086d 100755 (executable)
 # You should have received a copy of the GNU General Public License
 # along with Koha; if not, see <http://www.gnu.org/licenses>.
 
-use strict;
-use warnings;
+use Modern::Perl;
 use CGI qw ( -utf8 );
 use C4::Context;
 use C4::Output;
 use C4::Auth;
 use C4::Koha;
 use C4::Debug;
-use C4::Branch; # GetBranches
 use C4::HoldsQueue qw(TransportCostMatrix UpdateTransportCostMatrix);
 
+use Koha::Libraries;
+
 use Data::Dumper;
 
 my $input = new CGI;
@@ -42,7 +42,7 @@ my ($template, $loggedinuser, $cookie)
                             });
 my $use_transport_cost_matrix = C4::Context->preference("UseTransportCostMatrix");
 
-my $update = $input->param('op') eq 'set-cost-matrix';
+my $update = ( $input->param('op') // '' ) eq 'set-cost-matrix';
 
 my ($cost_matrix, $have_matrix);
 unless ($update) {
@@ -50,12 +50,8 @@ unless ($update) {
     $have_matrix = keys %$cost_matrix if $cost_matrix;
 }
 
-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' });
+my (@branchfromloop, @errors);
 foreach my $branchfrom ( @branchloop ) {
     my $fromcode = $branchfrom->{code};