Bug 12648: Fix conflict with bug 8096
[koha.git] / admin / transport-cost-matrix.pl
index 25d3911..54d8785 100755 (executable)
@@ -19,7 +19,7 @@
 
 use strict;
 use warnings;
-use CGI;
+use CGI qw ( -utf8 );
 use C4::Context;
 use C4::Output;
 use C4::Auth;
@@ -33,7 +33,7 @@ use Data::Dumper;
 my $input = new CGI;
 
 my ($template, $loggedinuser, $cookie)
-    = get_template_and_user({template_name => "admin/transport-cost-matrix.tmpl",
+    = get_template_and_user({template_name => "admin/transport-cost-matrix.tt",
                             query => $input,
                             type => "intranet",
                             authnotrequired => 0,
@@ -82,7 +82,7 @@ foreach my $branchfrom ( @branchloop ) {
                 $from_to_input_def{disabled} = 1;
             }
             else {
-                push @errors, "Invalid value for $from_row{name} -> $from_to_input_def{name}"
+                push @errors, "$from_row{name} -> $from_to_input_def{name}"
                   unless $value =~ /\d/o && $value >= 0.0;
             }
         }
@@ -91,8 +91,12 @@ foreach my $branchfrom ( @branchloop ) {
                 if ( my $cell = $cost_matrix->{$tocode}{$fromcode} ) {
                     $from_to_input_def{value} = $cell->{cost};
                     $from_to_input_def{disabled} = 1 if $cell->{disable_transfer};
+                } else {
+                    # matrix has been previously initialized, but a branch referenced here was created afterward.
+                    $from_to_input_def{disabled} = 1;
                 }
             } else {
+                # First time initializing the matrix
                 $from_to_input_def{disabled} = 1;
             }
         }