From 76338220ddf688f6e38488624dd260e0810db1c3 Mon Sep 17 00:00:00 2001 From: Marcel de Rooy Date: Wed, 15 Dec 2010 18:11:28 -0500 Subject: [PATCH] Bug 5374 (update transaction date when saving biblio) RESENT with small fix 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 Signed-off-by: Chris Cormack --- C4/Biblio.pm | 9 +++++++ cataloguing/value_builder/marc21_field_005.pl | 25 +++---------------- 2 files changed, 13 insertions(+), 21 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index c3a30946db..879dd0a054 100644 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -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") ) { diff --git a/cataloguing/value_builder/marc21_field_005.pl b/cataloguing/value_builder/marc21_field_005.pl index 7db29b7d18..2be76b5591 100755 --- a/cataloguing/value_builder/marc21_field_005.pl +++ b/cataloguing/value_builder/marc21_field_005.pl @@ -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 = "