From 0cd9d2f1842a93beb4dfb5cba26c64602bdf2d68 Mon Sep 17 00:00:00 2001 From: Janusz Kaczmarek Date: Thu, 27 Apr 2023 01:04:48 +0200 Subject: [PATCH] Bug 36552: Update record 'date entered on file' when duplicating a record The 'date entered on file' (MARC21: 008/0-5, UNIMARC: 100a/0=7) of a record created by duplication of an existing record should be set to the current date instead of having the value of the original record. Test plan ========= 1. Check the 'date entered on file' of an existing biblio / authotiry record (MARC21: 008/0-5, UNIMARC: 100a/0=7). 2. Duplicate the record by Edit > Edit as new (duplicate) 3. Control the 'date entered on file' value - it will equal to that of the original record. 4. Apply the patch (restart plack). 5. Repeat step 2. 6. Check the date - it should be the current date. Signed-off-by: Victor Grousset/tuxayo Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer (cherry picked from commit dd8f9e1266f2b93b0d57f1f1289d49f61129391e) Signed-off-by: Fridolin Somers --- authorities/authorities.pl | 11 +++++++++++ cataloguing/addbiblio.pl | 13 +++++++++++++ 2 files changed, 24 insertions(+) diff --git a/authorities/authorities.pl b/authorities/authorities.pl index da4eec62ee..e016da793d 100755 --- a/authorities/authorities.pl +++ b/authorities/authorities.pl @@ -637,6 +637,17 @@ if ($op eq "add") { } else { if ( $op eq "duplicate" ) { $authid = ""; + if ( C4::Context->preference('marcflavour') eq 'MARC21' && $record->field('008') ) { + my $s008 = $record->field('008')->data; + my $date = POSIX::strftime( "%y%m%d", localtime ); + substr( $s008, 0, 6, $date ); + $record->field('008')->update($s008); + } elsif ( C4::Context->preference('marcflavour') eq 'UNIMARC' && $record->subfield( '100', 'a' ) ) { + my $s100a = $record->subfield( '100', 'a' ); + my $date = POSIX::strftime( "%Y%m%d", localtime ); + substr( $s100a, 0, 8, $date ); + $record->field('100')->update( a => $s100a ); + } } if ( $changed_authtype eq "changed" ) { diff --git a/cataloguing/addbiblio.pl b/cataloguing/addbiblio.pl index e84c542092..bd6b9dc3d9 100755 --- a/cataloguing/addbiblio.pl +++ b/cataloguing/addbiblio.pl @@ -602,6 +602,19 @@ if ( $record && $op eq 'duplicate' && my @control_num = $record->field('001'); $record->delete_fields(@control_num); } +if ( $record && $op eq 'duplicate' ) { + if ( C4::Context->preference('marcflavour') eq 'MARC21' && $record->field('008') ) { + my $s008 = $record->field('008')->data; + my $date = POSIX::strftime( "%y%m%d", localtime ); + substr( $s008, 0, 6, $date ); + $record->field('008')->update($s008); + } elsif ( C4::Context->preference('marcflavour') eq 'UNIMARC' && $record->subfield( '100', 'a' ) ) { + my $s100a = $record->subfield( '100', 'a' ); + my $date = POSIX::strftime( "%Y%m%d", localtime ); + substr( $s100a, 0, 8, $date ); + $record->field('100')->update( a => $s100a ); + } +} #populate hostfield if hostbiblionumber is available if ($hostbiblionumber) { my $marcflavour = C4::Context->preference("marcflavour"); -- 2.39.5