Bug 12495 - Include streetnumber in hold alert address
[koha_fer] / authorities / merge.pl
index 3d4b881..3628381 100755 (executable)
@@ -6,7 +6,7 @@
 #
 # Koha is free software; you can redistribute it and/or modify it under the
 # terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
+# Foundation; either version 3 of the License, or (at your option) any later
 # version.
 #
 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
@@ -68,6 +68,7 @@ if ($merge) {
             require C4::ImportBatch;
             C4::ImportBatch::SetImportRecordStatus( $recordid2, 'imported' );
         } else {
+            C4::AuthoritiesMarc::merge( $recordid2, GetAuthority($recordid2), $recordid1, $record );
             $error = (DelAuthority($recordid2) == 0);
         }
         push @errors, $error if ($error);
@@ -94,9 +95,8 @@ else {
         my $recordObj1 = Koha::Authority->get_from_authid($authid[0]) || Koha::Authority->new();
         my $recordObj2;
 
-        if ($mergereference eq 'breeding') {
+        if (defined $mergereference && $mergereference eq 'breeding') {
             $recordObj2 =  Koha::Authority->get_from_breeding($authid[1]) || Koha::Authority->new();
-            $mergereference = $authid[0];
         } else {
             $recordObj2 =  Koha::Authority->get_from_authid($authid[1]) || Koha::Authority->new();
         }
@@ -106,11 +106,14 @@ else {
             my $framework;
             if ( $recordObj1->authtype ne $recordObj2->authtype && $mergereference ne 'breeding' ) {
                 $framework = $input->param('frameworkcode')
-                  or push @errors, "Framework not selected.";
+                  or push @errors, { code => 'FRAMEWORK_NOT_SELECTED' };
             }
             else {
                 $framework = $recordObj1->authtype;
             }
+            if ($mergereference eq 'breeding') {
+                $mergereference = $authid[0];
+            }
 
             # Getting MARC Structure
             my $tagslib = GetTagsLabels( 1, $framework );
@@ -167,12 +170,31 @@ else {
                     frameworkselect => \@frameworkselect,
                     frameworkcode1  => $recordObj1->authtype,
                     frameworkcode2  => $recordObj2->authtype,
+                    frameworklabel1 => $frameworks->{$recordObj1->authtype}->{'authtypetext'},
+                    frameworklabel2 => $frameworks->{$recordObj2->authtype}->{'authtypetext'},
                 );
             }
         }
     }
 }
 
+my $authtypes = getauthtypes;
+my @authtypesloop;
+foreach my $thisauthtype (
+    sort {
+        $authtypes->{$a}{'authtypetext'} cmp $authtypes->{$b}{'authtypetext'}
+    }
+    keys %$authtypes
+  )
+{
+    my %row = (
+        value        => $thisauthtype,
+        authtypetext => $authtypes->{$thisauthtype}{'authtypetext'},
+    );
+    push @authtypesloop, \%row;
+}
+$template->{VARS}->{authtypesloop} = \@authtypesloop;
+
 if (@errors) {
 
     # Errors