Adding 100$a coded field for UNIMARCAUTH and 152$b for any add
authorHenri-Damien LAURENT <henridamien@koha-fr.org>
Thu, 20 Dec 2007 14:23:06 +0000 (15:23 +0100)
committerJoshua Ferraro <jmf@liblime.com>
Fri, 21 Dec 2007 00:26:12 +0000 (18:26 -0600)
Signed-off-by: Chris Cormack <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/AuthoritiesMarc.pm

index 3da0b70..e910e0b 100644 (file)
@@ -508,6 +508,19 @@ sub AddAuthority {
 # if authid empty => true add, find a new authid number
   my $format= 'UNIMARCAUTH' if (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC');
   $format= 'MARC21' if (uc(C4::Context->preference('marcflavour')) ne 'UNIMARC');
+  if (($format eq "UNIMARCAUTH") && (!$record->subfield('100','a'))){
+        $record->leader("     nx  j22             ");
+        my $date=POSIX::strftime("%Y%m%d",localtime);    
+        if ($record->field('100')){
+          $record->field('100')->update('a'=>$date."afrey50      ba0");
+        } else {      
+          $record->append_fields(
+            MARC::Field->new('100',' ',' '
+              ,'a'=>$date."afrey50      ba0")
+          );
+        }      
+  }    
+  $record->add_fields('152','','','b'=>$authtypecode) unless ($record->field('152') && $record->subfield('152','b'));
   if (!$authid) {
     my $sth=$dbh->prepare("select max(authid) from auth_header");
     $sth->execute;
@@ -518,19 +531,6 @@ sub AddAuthority {
         $record->delete_field($record->field('001'));
         $record->insert_fields_ordered(MARC::Field->new('001',$authid));
     }
-    if (($format eq "UNIMARCAUTH") && (!$record->subfield('100','a'))){
-        $record->leader("     nx  j22             ");
-        my $date=POSIX::strftime("%Y%m%d",localtime);    
-        if ($record->field('100')){
-            $record->field('100')->update('a'=>$date."afrey50      ba0");
-        } else {      
-            $record->append_fields(
-            MARC::Field->new('100',' ',' '
-                ,'a'=>$date."afrey50      ba0")
-            );
-        }      
-    }    
-    $record->add_fields('152','','','b'=>$authtypecode) unless $record->field('152');
 #     warn $record->as_formatted;
     $dbh->do("lock tables auth_header WRITE");
     $sth=$dbh->prepare("insert into auth_header (authid,datecreated,authtypecode,marc,marcxml) values (?,now(),?,?,?)");
@@ -538,19 +538,6 @@ sub AddAuthority {
     $sth->finish;
   }else{
       $record->add_fields('001',$authid) unless ($record->field('001'));
-      if (($format eq "UNIMARCAUTH") && (!$record->subfield('100','a'))){
-            $record->leader("     nx  j22             ");
-            my $date=POSIX::strftime("%Y%m%d",localtime);    
-            if ($record->field('100')){
-              $record->field('100')->update('a'=>$date."afrey50      ba0");
-            } else {      
-              $record->append_fields(
-                MARC::Field->new('100',' ',' '
-                  ,'a'=>$date."afrey50      ba0")
-              );
-            }      
-      }    
-      $record->add_fields('152','','','b'=>$authtypecode) unless ($record->field('152'));
       $dbh->do("lock tables auth_header WRITE");
       my $sth=$dbh->prepare("update auth_header set marc=?,marcxml=? where authid=?");
       $sth->execute($record->as_usmarc,$record->as_xml_record($format),$authid);