Fix for Bug 3347 - Inconsistencies with tables in opac-shelves.tmpl
[koha.git] / C4 / Biblio.pm
index 4102e23..879dd0a 100644 (file)
@@ -1269,8 +1269,12 @@ sub GetMarcControlnumber {
     # Control number or Record identifier are the same field in MARC21 and UNIMARC
     # Keep $marcflavour for possible later use
     if ($marcflavour eq "MARC21" || $marcflavour eq "UNIMARC") {
-        $controlnumber = $record->field('001')->data();
+        my $controlnumberField = $record->field('001');
+        if ($controlnumberField) {
+            $controlnumber = $controlnumberField->data();
+        }
     }
+    return $controlnumber;
 }
 
 =head2 GetMarcNotes
@@ -3237,6 +3241,15 @@ sub ModBiblioMarc {
             $record->insert_grouped_field( MARC::Field->new( 100, "", "", "a" => $string ) );
         }
     }
+
+    #enhancement 5374: update transaction date (005) for marc21/unimarc
+    if($encoding =~ /MARC21|UNIMARC/) {
+      my @a= (localtime) [5,4,3,2,1,0]; $a[0]+=1900; $a[1]++;
+        # YY MM DD HH MM SS (update year and month)
+      my $f005= $record->field('005');
+      $f005->update(sprintf("%4d%02d%02d%02d%02d%04.1f",@a)) if $f005;
+    }
+
     my $oldRecord;
     if ( C4::Context->preference("NoZebra") ) {