- my $hits = $show_results;
- my (@results, @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++) {
- #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,'');
- # Begin building the hash for the template...
- # I don't think we need this with the current template design, but I'm leaving it in place. -fbcit
- #$biblio->{highlight} = ($i % 2)?(1):(0);
- #DEBUG Notes: Stuff the bib into @results...
- push @results, $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...
- my $iii = $itemnums->{$biblionumber};
- if ($iii) {
- 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[$i]->{'biblionumber'}) {
- # NOTE: The order of the elements in this array must be preserved or the table dependent on it will be incorrectly rendered.
- # This is a real hack, but I can't think of a better way right now. -fbcit
- # It is conceivable that itemcallnumber and/or barcode fields might be empty so the trinaries cover this possibility.
- push @{$results[$i]->{'item'}}, { i_itemnumber1 => $item_results->{$item}->{'itemnumber'} };
- push @{$results[$i]->{'item'}}, { i_itemcallnumber => ($item_results->{$item}->{'itemcallnumber'} ? $item_results->{$item}->{'itemcallnumber'} : 'NA') };
- push @{$results[$i]->{'item'}}, { i_dateaccessioned => $item_results->{$item}->{'dateaccessioned'} };
- push @{$results[$i]->{'item'}}, { i_barcode => ($item_results->{$item}->{'barcode'} ? $item_results->{$item}->{'barcode'} : 'NA')};
- push @{$results[$i]->{'item'}}, { i_itemnumber2 => $item_results->{$item}->{'itemnumber'} };
- }
- }
- }
- }
- $debug and warn "**********\@results**********\n";
- $debug and warn Dumper(@results);
-
- my @field_data = ();
-
- # FIXME: this relies on symmetric order of CGI params that IS NOT GUARANTEED by spec.
-
- for ( my $i = 0 ; $i <= $#marclist ; $i++ ) {
- push @field_data, { term => "marclist", val => $marclist[$i] };
- push @field_data, { term => "and_or", val => $and_or[$i] };
- push @field_data, { term => "excluding", val => $excluding[$i] };
- push @field_data, { term => "operator", val => $operator[$i] };
- push @field_data, { term => "value", val => $value[$i] };
- }
-
- my @numbers = ();