+if ($show_results) {
+ my $hits = $show_results;
+ my @results_set = ();
+ my @items =();
+ # This code needs to be refactored using these subs...
+ #my @items = &GetItemsInfo( $biblio->{biblionumber}, 'intra' );
+ #my $dat = &GetBiblioData( $biblio->{biblionumber} );
+ for ( my $i = 0 ; $i < $hits ; $i++ ) {
+ my @row_data= ();
+ #DEBUG Notes: Decode the MARC record from each resulting MARC record...
+ my $marcrecord = MARC::File::USMARC::decode( $marcresults->[$i] );
+ #DEBUG Notes: Transform it to Koha form...
+ my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
+ #DEBUG Notes: Stuff the bib into @biblio_data...
+ push (@results_set, $biblio);
+ my $biblionumber = $biblio->{'biblionumber'};
+ #DEBUG Notes: Grab the item numbers associated with this MARC record...
+ my $itemnums = get_itemnumbers_of($biblionumber);
+ #DEBUG Notes: Retrieve the item data for each number...
+ if (my $iii = $itemnums->{$biblionumber}) {
+ my $item_results = GetItemInfosOf(@$iii);
+ foreach my $item ( keys %$item_results ) {
+ #DEBUG Notes: Build an array element 'item' of the correct bib (results) hash which contains item-specific data...
+ if ($item_results->{$item}->{'biblionumber'} eq $results_set[$i]->{'biblionumber'}) {
+ my $item_data;
+ $item_data->{'_item_number'} = $item_results->{$item}->{'itemnumber'};
+ $item_data->{'_item_call_number'} = ($item_results->{$item}->{'itemcallnumber'} ? $item_results->{$item}->{'itemcallnumber'} : 'NA');
+ $item_data->{'_date_accessioned'} = $item_results->{$item}->{'dateaccessioned'};
+ $item_data->{'_barcode'} = ( $item_results->{$item}->{'barcode'} ? $item_results->{$item}->{'barcode'} : 'NA');
+ $item_data->{'_add'} = $item_results->{$item}->{'itemnumber'};
+ unshift (@row_data, $item_data); # item numbers are given to us in descending order by get_itemnumbers_of()...
+ }
+ }
+ $results_set[$i]->{'item_table'} = html_table($display_columns, \@row_data);