Ticket 1110 : Balance carts and lists
[koha.git] / virtualshelves / addbybiblionumber.pl
index fd3c2d6..69a2c06 100755 (executable)
@@ -61,6 +61,20 @@ use C4::Output;
 use C4::VirtualShelves qw/:DEFAULT GetRecentShelves/;
 use C4::Circulation;
 use C4::Auth;
+#splits incoming biblionumber(s) to array and adds each to shelf.
+sub AddBibliosToShelf {
+    my ($shelfnumber,@biblionumber)=@_;
+
+    # multiple bibs might come in as '/' delimited string (from where, i don't see), or as array.
+    if (scalar(@biblionumber) == 1) {
+        @biblionumber = (split /\//,$biblionumber[0]);
+    }
+    for my $bib (@biblionumber){
+        AddToShelfFromBiblio($bib, $shelfnumber);
+    }
+}
+
+
 
 #use it only to debug !
 use warnings;
@@ -83,13 +97,15 @@ my $query           = new CGI;
 my $biblionumber    = $query->param('biblionumber');
 
 # If set, then multiple item case.
-
+my @biblionumber   = $query->param('biblionumber');
 my $biblionumbers   = $query->param('biblionumbers');
+
 my $shelfnumber     = $query->param('shelfnumber');
 my $newvirtualshelf = $query->param('newvirtualshelf');
 my $category        = $query->param('category');
-my $confirmed        = $query->param('confirmed');
-my $sortfield          = $query->param('sortfield');
+my $sortfield      = $query->param('sortfield');
+my $confirmed       = $query->param('confirmed') || 0;
+
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
@@ -111,8 +127,9 @@ if ($biblionumbers) {
 $shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category, $sortfield )
   if $newvirtualshelf;
 if ( $shelfnumber || ( $shelfnumber == -1 ) ) {    # the shelf already exist.
+
     if ($confirmed == 1) {
-       AddBibliosToShelf($shelfnumber,@biblionumbers);
+       AddBibliosToShelf($shelfnumber,@biblionumber);
        print
     "Content-Type: text/html\n\n<html><body onload=\"window.opener.location.reload(true);window.close()\"></body></html>";
        exit;