+my $authvalcode_items_itemlost = GetAuthValCode('items.itemlost',$fw);
+my $authvalcode_items_damaged = GetAuthValCode('items.damaged', $fw);
+foreach my $item (@items) {
+
+ # can place holds defaults to yes
+ $norequests = 0 unless ( ( $item->{'notforloan'} > 0 ) || ( $item->{'itemnotforloan'} > 0 ) );
+
+ # format some item fields for display
+ if ( defined $item->{'publictype'} ) {
+ $item->{ $item->{'publictype'} } = 1;
+ }
+ $item->{imageurl} = defined $item->{itype} ? getitemtypeimagelocation('intranet', $itemtypes->{ $item->{itype} }{imageurl})
+ : '';
+
+ foreach (qw(datedue datelastseen onloan)) {
+ $item->{$_} = format_date($item->{$_});
+ }
+ # item damaged, lost, withdrawn loops
+ $item->{itemlostloop} = GetAuthorisedValues($authvalcode_items_itemlost, $item->{itemlost}) if $authvalcode_items_itemlost;
+ if ($item->{damaged}) {
+ $item->{itemdamagedloop} = GetAuthorisedValues($authvalcode_items_damaged, $item->{damaged}) if $authvalcode_items_damaged;
+ }
+ #get shelf location and collection code description if they are authorised value.
+ my $shelfcode = $item->{'location'};
+ $item->{'location'} = $shelflocations->{$shelfcode} if ( defined( $shelfcode ) && defined($shelflocations) && exists( $shelflocations->{$shelfcode} ) );
+ my $ccode = $item->{'ccode'};
+ $item->{'ccode'} = $collections->{$ccode} if ( defined( $ccode ) && defined($collections) && exists( $collections->{$ccode} ) );
+ foreach (qw(ccode enumchron copynumber)) {
+ $itemfields{$_} = 1 if ( $item->{$_} );
+ }
+
+ # checking for holds
+ my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($item->{itemnumber});
+ my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0);
+
+ if ( defined $reservedate ) {
+ $item->{backgroundcolor} = 'reserved';
+ $item->{reservedate} = format_date($reservedate);
+ $item->{ReservedForBorrowernumber} = $reservedfor;
+ $item->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'};
+ $item->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'};
+ $item->{ExpectedAtLibrary} = $branches->{$expectedAt}{branchname};
+ }
+
+ # Check the transit status
+ my ( $transfertwhen, $transfertfrom, $transfertto ) = GetTransfers($item->{itemnumber});
+ if ( defined( $transfertwhen ) && ( $transfertwhen ne '' ) ) {
+ $item->{transfertwhen} = format_date($transfertwhen);
+ $item->{transfertfrom} = $branches->{$transfertfrom}{branchname};
+ $item->{transfertto} = $branches->{$transfertto}{branchname};
+ $item->{nocancel} = 1;
+ }
+
+ # FIXME: move this to a pm, check waiting status for holds
+ my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'");
+ $sth2->execute($item->{ReservedForBorrowernumber},$item->{itemnumber});
+ while (my $wait_hashref = $sth2->fetchrow_hashref) {
+ $item->{waitingdate} = format_date($wait_hashref->{waitingdate});
+ }
+
+ push @itemloop, $item;