Bug 5374 (update transaction date when saving biblio) RESENT with small fix
authorMarcel de Rooy <M.de.Rooy@rijksmuseum.nl>
Wed, 15 Dec 2010 23:11:28 +0000 (18:11 -0500)
committerChris Cormack <chrisc@catalyst.net.nz>
Tue, 4 Jan 2011 19:42:47 +0000 (08:42 +1300)
Currently, the plugin marc21_field_005 and its unimarc opponent fill field 005
when this field gets focus. This implies that updating a record without
touching this field does not update 005.
At the same time, a user could accidentally delete a character in the 005 when
having focus. This mutilated field value will be saved however.

I would suggest to add a few lines to ModBiblioMarc in Biblio.pm to ascertain
that adding or updating a record always updates 005 in marc21 as well as
unimarc.

Signed-off-by: Nicole Engard <nengard@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
C4/Biblio.pm
cataloguing/value_builder/marc21_field_005.pl

index c3a3094..879dd0a 100644 (file)
@@ -3241,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") ) {
 
index 7db29b7..2be76b5 100755 (executable)
@@ -19,7 +19,7 @@
 
 use strict;
 #use warnings; FIXME - Bug 2505
-use C4::Context;
+#use C4::Context;
 
 =head1
 
@@ -52,26 +52,9 @@ sub plugin_javascript {
     my $function_name= $field_number;
 
     # find today's date
-    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
-    $year +=1900;
-    $mon +=1;
-    if (length($mon)==1) {
-        $mon = "0".$mon;
-    }
-    if (length($mday)==1) {
-        $mday = "0".$mday;
-    }
-    if (length($hour)==1) {
-        $hour = "0".$hour;
-    }
-    if (length($min)==1) {
-        $min = "0".$min;
-    }
-    if (length($sec)==1) {
-        $hour = "0".$sec;
-    }
-
-    my $date = "$year$mon$mday$hour$min$sec".".0";
+    my @a= (localtime) [5,4,3,2,1,0]; $a[0]+=1900; $a[1]++;
+    my $date = sprintf("%4d%02d%02d%02d%02d%04.1f",@a);
+
     my $res  = "
 <script type=\"text/javascript\">
 //<![CDATA[