From 56c262853104f70bcbd91cdfc2e2c6f6d25812da Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 5 Jan 2021 09:03:31 +0100 Subject: [PATCH] Bug 24488: create a loop to avoid copy paste --- circ/pendingreserves.pl | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/circ/pendingreserves.pl b/circ/pendingreserves.pl index bc7b25b001..d8c9cf4243 100755 --- a/circ/pendingreserves.pl +++ b/circ/pendingreserves.pl @@ -272,23 +272,22 @@ foreach my $bibnum ( @biblionumbers ){ } $hold_info->{itemtypes} = \@res_itemtypes; - # get available locations for each biblio - $hold_info->{locations} = [ uniq map { defined $_->location ? $_->location : () } @$items ]; - - # get available callnumbers for each biblio - $hold_info->{callnumbers} = [ uniq map { defined $_->itemcallnumber ? $_->itemcallnumber : () } @$items ]; - - # get available enumchrons for each biblio - $hold_info->{enumchrons} = [ uniq map { defined $_->enumchron ? $_->enumchron : () } @$items ]; - - # get available copynumbers for each biblio - $hold_info->{copynumbers} = [ uniq map { defined $_->copynumber ? $_->copynumber : () } @$items ]; - - # get available barcodes for each biblio - $hold_info->{barcodes} = [ uniq map { defined $_->barcode ? $_->barcode : () } @$items ]; - - # get available holding branches for each biblio - $hold_info->{holdingbranches} = [ uniq map { defined $_->holdingbranch ? $_->holdingbranch : () } @$items ]; + # get available values for each biblio + my $fff = { + locations => 'location', + callnumbers => 'itemcallnumber', + enumchrons => 'enumchron', + copynumbers => 'copynumber', + barcodes => 'barcode', + holdingbranches => 'holdingbranch' + }; + + while ( + my ( $k, $f ) = each %$fff ) + { + $hold_info->{$k} = + [ uniq map { defined $_->$f ? $_->$f : () } @$items ]; + } # items available $hold_info->{items_count} = $items_count; -- 2.20.1