-my $count2 = @results;
-if ( $keyword ne '' && $offset > 0 ) {
- $count2 = $count - $offset;
- if ( $count2 > 10 ) {
- $count2 = 10;
- }
-}
-my $i = 0;
-my $colour = 0;
-
-my @loopresult;
-
-while ( $i < $count2 ) {
- my %lineres;
- my $toggle;
-
- my $result = $results[$i];
- $result->{'title'} =~ s/\`/\\\'/g;
- my $title2 = $result->{'title'};
- my $author2 = $result->{'author'};
- $author2 =~ s/ /%20/g;
- $title2 =~ s/ /%20/g;
- $title2 =~ s/\#/\&\#x23;/g;
- $title2 =~ s/\"/\"\;/g;
-
- my $itemcount;
- my $location = '';
- my $location_only = '';
- my $word = $result->{'author'};
- $word =~ s/([a-z]) +([a-z])/$1%20$2/ig;
- $word =~ s/ //g;
- $word =~ s/ /%20/g;
- $word =~ s/\,/\,%20/g;
- $word =~ s/\n//g;
- $lineres{word} = $word;
- $lineres{type} = $type;
-
- my ( $counts, $branchcounts ) =
- C4::Search::itemcount( $env, $result->{'biblionumber'}, $type );
-
- if ( $counts->{'nacount'} > 0 ) {
- $location .= "On Loan";
- if ( $counts->{'nacount'} > 1 ) {
- $location .= "=($counts->{'nacount'})";
- }
- $location .= " ";
- $lineres{'on-loan-p'} = 1;
- }
- foreach my $key ( keys %$branchcounts ) {
- if ( $branchcounts->{$key} > 0 ) {
- $location .= $key;
- $location_only .= $key;
-
- if ( $branchcounts->{$key} > 1 ) {
- $location .= "=$branchcounts->{$key}";
- $location_only .= "=$branchcounts->{$key}";
- }
- $location .= " ";
- $location_only .= " ";
- }
- }
- if ( $counts->{'lostcount'} > 0 ) {
- $location .= "Lost";
- if ( $counts->{'lostcount'} > 1 ) {
- $location .= "=($counts->{'lostcount'})";
- }
- $location .= " ";
- $lineres{'lost-p'} = 1;
- }
- if ( $counts->{'mending'} > 0 ) {
- $location .= "Mending";
- if ( $counts->{'mending'} > 1 ) {
- $location .= "=($counts->{'mending'})";
- }
- $location .= " ";
- $lineres{'mending-p'} = 1;
- }
- if ( $counts->{'transit'} > 0 ) {
- $location .= "In Transit";
- if ( $counts->{'transit'} > 1 ) {
- $location .= "=($counts->{'transit'})";
- }
- $location .= " ";
- $lineres{'in-transit-p'} = 1;
- }
- if ( $colour eq 0 ) {
- $toggle = 1;
- $colour = 1;
- }
- else {
- $colour = 0;
- $toggle = 0;
- }
- $lineres{author2} = $author2;
- $lineres{title2} = $title2;
- $lineres{copyright} = $result->{'copyrightdate'};
- $lineres{booksellerid} = $booksellerid;
- $lineres{basketno} = $basketno;
- $lineres{sub} = $sub;
- $lineres{biblionumber} = $result->{biblionumber};
- $lineres{title} = $result->{title};
- $lineres{author} = $result->{author};
- $lineres{toggle} = $toggle;
- $lineres{itemcount} = $counts->{'count'};
- $lineres{location} = $location;
- $lineres{'location-only'} = $location_only;
-
- # lets get a list on existing orders for all bibitems.
- my @bibitems = GetBiblioItemByBiblioNumber( $result->{biblionumber} );
- my $count1 = scalar @bibitems;
- my $order, my $ordernumber;
-
- my $i1 = 0;
-
- my @ordernumbers;
- foreach my $bibitem (@bibitems) {
- my $ordernumber = GetOrderNumber($result->{biblionumber},$bibitem->{biblioitemnumber});
- $order = &GetOrder($ordernumber);
-
- #only show order if its current;
- my %order;
- $order{'number'} = $ordernumber;
- if ( ( !$order->{cancelledby} )
- && ( $order->{quantityreceived} < $order->{quantity} ) )
- {
- push @ordernumbers, \%order;
- }
- }
- $lineres{existingorder} = \@ordernumbers;
- push( @loopresult, \%lineres );
- $i++;
-}