From: Chris Nighswonger Date: Wed, 12 Mar 2008 14:33:43 +0000 (-0400) Subject: Fixes to enable display and selection of individual items rather than bibs. X-Git-Tag: v3.00.00-beta~127 X-Git-Url: http://git.rot13.org/?a=commitdiff_plain;h=025d4441e54c8bb7eb659fff8aa0d89c09d1515e;p=koha.git Fixes to enable display and selection of individual items rather than bibs. Signed-off-by: Joshua Ferraro --- diff --git a/labels/label-item-search.pl b/labels/label-item-search.pl index 65a6859855..c1a96f3f29 100755 --- a/labels/label-item-search.pl +++ b/labels/label-item-search.pl @@ -34,7 +34,7 @@ use C4::Dates qw( DHTMLcalendar ); use C4::Koha; # XXX subfield_is_koha_internal_p #use Smart::Comments; -#use Data::Dumper; +use Data::Dumper; # Creates a scrolling list with the associated default value. # Using more than one scrolling list in a CGI assigns the same default value to all the @@ -78,29 +78,40 @@ if ( $op eq "do_search" ) { if ( $show_results ) { my $hits = $show_results; my (@results,@results2); + # 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 $marcrecord = MARC::File::USMARC::decode($marcresults->[$i]); - my $biblio = TransformMarcToKoha(C4::Context->dbh,$marcrecord,''); - #build the hash for the template. - $biblio->{highlight} = ($i % 2)?(1):(0); - #warn $biblio->{biblionumber}; - push @results, $biblio; - my $biblionumber = $biblio->{'biblionumber'}; - my $itemnums = get_itemnumbers_of($biblionumber); - my $iii = $itemnums->{$biblionumber} ; - if ($iii) { - my $item_results = &GetItemInfosOf( @$iii ); + #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,''); + #build the hash for the template. + $biblio->{highlight} = ($i % 2)?(1):(0); + #DEBUG Notes: Stuff it into @results... (used below to supply fields not existing in the item data) + 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 @titem_results = GetItemsInfo( $itemnums->{$biblionumber}, 'intra' ); + my $item_results = GetItemInfosOf( @$iii ); foreach my $item (keys %$item_results) { - for my $bibdata (keys %{$results[$i]}) { - #warn Dumper($bibdata); - #warn Dumper($results[$i]->{$bibdata}); - $item_results->{$item}{$bibdata} = $results[$i]->{$bibdata}; - } - push @results2, $item_results->{$item}; - } + for my $bibdata (keys %{$results[$i]}) { + if ( !$item_results->{$item}{$bibdata} ) { #Only add the data from the bibliodata if the data does not already exit in itemdata. + #Otherwise we just build duplicate records rather than unique records per item. + $item_results->{$item}{$bibdata} = $results[$i]->{$bibdata}; + } + } + #DEBUG Notes: After merging the bib and item data, stuff the results into $results2... + push @results2, $item_results->{$item}; } + #warn Dumper(@results2); + } } - ( $template, $loggedinuser, $cookie ) = get_template_and_user( + ( $template, $loggedinuser, $cookie ) = get_template_and_user( { template_name => "labels/result.tmpl", query => $query,