X-Git-Url: http://koha-dev.rot13.org:8081/gitweb/?a=blobdiff_plain;f=virtualshelves%2Faddbybiblionumber.pl;h=d565493d62bddb9bb4d79b05dd45183bcf4eddbf;hb=ee83c4ae809e79c54ab43c93a28d578d1e87ed5a;hp=4862d02e4c3bc9126817fd9fc58482db8f9ae905;hpb=9971756a24e70101b2fb92833afab974d57ac4b9;p=koha_fer diff --git a/virtualshelves/addbybiblionumber.pl b/virtualshelves/addbybiblionumber.pl index 4862d02e4c..d565493d62 100755 --- a/virtualshelves/addbybiblionumber.pl +++ b/virtualshelves/addbybiblionumber.pl @@ -58,7 +58,7 @@ use strict; use C4::Biblio; use CGI; use C4::Output; -use C4::VirtualShelves; +use C4::VirtualShelves qw/:DEFAULT GetRecentShelves/; use C4::Circulation; use C4::Auth; @@ -67,7 +67,13 @@ use CGI::Carp qw/fatalsToBrowser/; use warnings; my $query = new CGI; + +# If set, then single item case. my $biblionumber = $query->param('biblionumber'); + +# If set, then multiple item case. +my $biblionumbers = $query->param('biblionumbers'); + my $shelfnumber = $query->param('shelfnumber'); my $newvirtualshelf = $query->param('newvirtualshelf'); my $category = $query->param('category'); @@ -83,50 +89,79 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); +my @biblionumbers; +if ($biblionumbers) { + @biblionumbers = split '/', $biblionumbers; +} else { + @biblionumbers = ($biblionumber); +} + $shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category, $sortfield ) if $newvirtualshelf; if ( $shelfnumber || ( $shelfnumber == -1 ) ) { # the shelf already exist. - AddToShelfFromBiblio( $biblionumber, $shelfnumber ); + foreach my $biblionumber (@biblionumbers) { + AddToShelfFromBiblio( $biblionumber, $shelfnumber ); + } print "Content-Type: text/html\n\n"; exit; } else { # this shelf doesn't already exist. - my ( $bibliocount, @biblios ) = GetBiblio($biblionumber); - - my $limit = 10; - my ($shelflist) = GetRecentShelves(1, $limit, $loggedinuser); + my $limit = 10; + my ($shelflist) = GetRecentShelves(1, $limit, $loggedinuser); my @shelvesloop; my %shelvesloop; - for my $shelf ( @{${@$shelflist}[0]} ) { + for my $shelf ( @{ $shelflist->[0] } ) { push( @shelvesloop, $shelf->{shelfnumber} ); - $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname}; - } - # then open shelves... - my ($shelflist) = GetRecentShelves(3, $limit, undef); - for my $shelf ( @{${@$shelflist}[0]} ) { + $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname}; + } + # then open shelves... + my ($shelflist) = GetRecentShelves(3, $limit, undef); + for my $shelf ( @{ $shelflist->[0] } ) { push( @shelvesloop, $shelf->{shelfnumber} ); - $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname}; - } - if(@shelvesloop gt 0){ - my $CGIvirtualshelves = CGI::scrolling_list( - -name => 'shelfnumber', - -values => \@shelvesloop, - -labels => \%shelvesloop, - -size => 1, - -tabindex => '', - -multiple => 0 - ); - $template->param( - CGIvirtualshelves => $CGIvirtualshelves, - ); - } - - $template->param( - biblionumber => $biblionumber, - title => $biblios[0]->{'title'}, - author => $biblios[0]->{'author'}, - ); - + $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname}; + } + if(@shelvesloop gt 0){ + my $CGIvirtualshelves = CGI::scrolling_list + ( + -name => 'shelfnumber', + -values => \@shelvesloop, + -labels => \%shelvesloop, + -size => 1, + -tabindex => '', + -multiple => 0 + ); + $template->param + ( + CGIvirtualshelves => $CGIvirtualshelves, + ); + } + + unless ($biblionumbers) { + my ( $bibliocount, @biblios ) = GetBiblio($biblionumber); + + $template->param + ( + biblionumber => $biblionumber, + title => $biblios[0]->{'title'}, + author => $biblios[0]->{'author'}, + ); + } else { + my @biblioloop = (); + foreach my $biblionumber (@biblionumbers) { + my ( $bibliocount, @biblios ) = GetBiblio($biblionumber); + my %biblioiter = ( + title=>$biblios[0]->{'title'}, + author=>$biblios[0]->{'author'} + ); + push @biblioloop, \%biblioiter; + } + $template->param + ( + biblioloop => \@biblioloop, + biblionumbers => $biblionumbers + ); + } + output_html_with_http_headers $query, $cookie, $template->output; }