Bug 19821: Use database_test entry if exists
[koha-ffzg.git] / Koha / Illrequest.pm
index 01d421f..7ea301f 100644 (file)
@@ -19,16 +19,13 @@ package Koha::Illrequest;
 
 use Modern::Perl;
 
-use Clone 'clone';
-use File::Basename qw( basename );
-use Encode qw( encode );
-use Try::Tiny;
+use Clone qw( clone );
+use Try::Tiny qw( catch try );
 use DateTime;
 
 use C4::Letters;
-use C4::Members;
 use Koha::Database;
-use Koha::DateUtils qw/ dt_from_string /;
+use Koha::DateUtils qw( dt_from_string );
 use Koha::Exceptions::Ill;
 use Koha::Illcomments;
 use Koha::Illrequestattributes;
@@ -41,7 +38,7 @@ use Koha::Items;
 use Koha::ItemTypes;
 use Koha::Libraries;
 
-use C4::Circulation qw( CanBookBeIssued AddIssue  );
+use C4::Circulation qw( CanBookBeIssued AddIssue );
 
 use base qw(Koha::Object);
 
@@ -721,7 +718,8 @@ Migrate a request from one backend to another.
 
 sub backend_migrate {
     my ( $self, $params ) = @_;
-
+    # Set the request's backend to be the destination backend
+    $self->load_backend($params->{backend});
     my $response = $self->_backend_capability('migrate',{
             request    => $self,
             other      => $params,
@@ -1558,7 +1556,8 @@ sub get_notice {
     );
     my $metahash = $self->metadata;
     my @metaarray = ();
-    while (my($key, $value) = each %{$metahash}) {
+    foreach my $key (sort { lc $a cmp lc $b } keys %{$metahash}) {
+        my $value = $metahash->{$key};
         push @metaarray, "- $key: $value" if $value;
     }
     my $metastring = join("\n", @metaarray);