From 37de3685a4d527663f98ca11d09b4d911e00a770 Mon Sep 17 00:00:00 2001 From: Aleisha Amohia Date: Wed, 11 Mar 2020 03:08:12 +0000 Subject: [PATCH] Bug 5103: (follow-up) Using mapped item fields instead of hardcoding subfields Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Joy Nelson --- catalogue/MARCdetail.pl | 8 ++++++-- cataloguing/additem.pl | 8 +++++++- opac/opac-MARCdetail.pl | 8 ++++++-- 3 files changed, 19 insertions(+), 5 deletions(-) diff --git a/catalogue/MARCdetail.pl b/catalogue/MARCdetail.pl index 3f58641f3b..af5b0da6ac 100755 --- a/catalogue/MARCdetail.pl +++ b/catalogue/MARCdetail.pl @@ -289,8 +289,12 @@ foreach my $field (@fields) { $norequests = 0 if $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.notforloan' and $subf[$i][1] == 0; - if ( $subf[$i][0] eq 'd' || $subf[$i][0] eq 'q' || $subf[$i][0] eq 'r' || $subf[$i][0] eq 's' || $subf[$i][0] eq 'w' ){ - # date accessioned || on loan || date last seen || date last borrowed || replacement price date + if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.dateaccessioned' || + $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.onloan' || + $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.datelastseen' || + $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.datelastborrowed' || + $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.replacementpricedate' + ){ $item->{$subf[$i][0]} = output_pref({ dt => dt_from_string( $item->{$subf[$i][0]} ), dateonly => 1 }); } } diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index 70c78b12fd..71366c8df4 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -861,7 +861,13 @@ for my $row ( @big_array ) { } else { $item_field->{field} = ''; } - if ( $key eq 'd' || $key eq 'q' || $key eq 'r' || $key eq 's' || $key eq 'w' ){ + + my ($tmpa, $dateaccessioned) = &GetMarcFromKohaField( "items.dateaccessioned" ); + my ($tmpb, $onloan) = &GetMarcFromKohaField( "items.onloan" ); + my ($tmpc, $datelastseen) = &GetMarcFromKohaField( "items.datelastseen" ); + my ($tmpd, $datelastborrowed) = &GetMarcFromKohaField( "items.datelastborrowed" ); + my ($tmpe, $replacementpricedate) = &GetMarcFromKohaField( "items.replacementpricedate" ); + if ( $key eq $dateaccessioned || $key eq $onloan || $key eq $datelastseen || $key eq $datelastborrowed || $key eq $replacementpricedate ){ # date accessioned || on loan || date last seen || date last borrowed || replacement price date $item_field->{field} = output_pref({ dt => dt_from_string( $row->{$key} ), dateonly => 1 }); } diff --git a/opac/opac-MARCdetail.pl b/opac/opac-MARCdetail.pl index 51c3651f3d..368093fe43 100755 --- a/opac/opac-MARCdetail.pl +++ b/opac/opac-MARCdetail.pl @@ -313,8 +313,12 @@ foreach my $field (@fields) { $subf[$i][1], '', $tagslib, '', 'opac' ); } - if ( $subf[$i][0] eq 'd' || $subf[$i][0] eq 'q' || $subf[$i][0] eq 'r' || $subf[$i][0] eq 's' || $subf[$i][0] eq 'w' ){ - # date accessioned || on loan || date last seen || date last borrowed || replacement price date + if ( $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.dateaccessioned' || + $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.onloan' || + $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.datelastseen' || + $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.datelastborrowed' || + $tagslib->{ $field->tag() }->{ $subf[$i][0] }->{kohafield} eq 'items.replacementpricedate' + ){ $item->{$subf[$i][0]} = output_pref({ dt => dt_from_string( $item->{$subf[$i][0]} ), dateonly => 1 });; } } -- 2.39.5