[Koha-patches] [PATCH] Bug 5374 (update transaction date when saving biblio) RESENT with small fix
Marcel de Rooy
M.de.Rooy at rijksmuseum.nl
Tue Nov 9 17:04:27 CET 2010
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.
---
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 81ccfbb..1b2098e 100644
--- a/C4/Biblio.pm
+++ b/C4/Biblio.pm
@@ -3217,6 +3217,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", at 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 3c33145..23d5a4b 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
@@ -51,26 +51,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", at a);
+
my $res = "
<script type=\"text/javascript\">
//<![CDATA[
--
1.6.0.6
More information about the Koha-patches
mailing list