Bug 5103: (follow-up) Using mapped item fields instead of hardcoding subfields
authorAleisha Amohia <aleishaamohia@hotmail.com>
Wed, 11 Mar 2020 03:08:12 +0000 (03:08 +0000)
committerMartin Renvoize <martin.renvoize@ptfs-europe.com>
Mon, 16 Mar 2020 10:56:36 +0000 (10:56 +0000)
Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>

catalogue/MARCdetail.pl
cataloguing/additem.pl
opac/opac-MARCdetail.pl

index 36b56a3..32b51e8 100755 (executable)
@@ -297,8 +297,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 });
         }
     }
index 109c76c..0a7fb25 100755 (executable)
@@ -864,7 +864,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 });
         }
index ada088f..0c4b2c7 100755 (executable)
@@ -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 });;
         }
     }