From 433be86631aa809c0262ed54172d7f3289b25116 Mon Sep 17 00:00:00 2001 From: Ryan Higgins Date: Sun, 9 Dec 2007 15:36:50 -0600 Subject: [PATCH] Add multiple items to virt shelf, and bugvix virtual shelf adds. Signed-off-by: Joshua Ferraro --- koha-tmpl/opac-tmpl/prog/en/js/basket.js | 24 +++++++-- .../en/modules/opac-addbybiblionumber.tmpl | 25 ++++----- .../prog/en/modules/opac-results.tmpl | 1 + opac/opac-addbybiblionumber.pl | 51 ++++++++----------- 4 files changed, 50 insertions(+), 51 deletions(-) diff --git a/koha-tmpl/opac-tmpl/prog/en/js/basket.js b/koha-tmpl/opac-tmpl/prog/en/js/basket.js index 5fd91a23b3..d761598fa2 100644 --- a/koha-tmpl/opac-tmpl/prog/en/js/basket.js +++ b/koha-tmpl/opac-tmpl/prog/en/js/basket.js @@ -159,11 +159,6 @@ function addMultiple(){ } } -function addSelToShelf() { - var items = document.getElementById('records').value; - document.location = "/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber="+items; -} - function addSelRecords(valSel) { // function for adding a selection of biblios to the basket // from the results list var arrayRecords = valSel.split("/"); @@ -371,3 +366,22 @@ function openBiblio(dest,biblionumber) { opener.document.location = openerURL; opener.focus(); } + +function addSelToShelf() { + var items = document.getElementById('records').value; + document.location = "/cgi-bin/koha/opac-addbybiblionumber.pl?biblionumber="+items; +} + +/// vShelfAdd() builds url string for multiple-biblio adds. + +function vShelfAdd() { + bibs= new Array; + if(document.bookbag_form.biblionumber.length > 0) { + for (var i=0; i < document.bookbag_form.biblionumber.length; i++) { + if (document.bookbag_form.biblionumber[i].checked) { + bibs.push("biblionumber=" + document.bookbag_form.biblionumber[i].value); + } + } + return bibs.join("&"); + } +} diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-addbybiblionumber.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-addbybiblionumber.tmpl index f28991b657..ebd4b0bfe5 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-addbybiblionumber.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-addbybiblionumber.tmpl @@ -9,26 +9,21 @@
-

Add these biblios to a shelf

- - - by -

- +

Add items to a book list:

-

Add - - - by - to a Virtual Shelf -

+

Add to a book list:

- +
    +
  • + +
  • + +
Select an Existing List
- " /> + ">
Cancel
@@ -48,7 +43,7 @@ - " /> + ">
Cancel
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl index 0b485db0bf..458648af47 100644 --- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl +++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-results.tmpl @@ -108,6 +108,7 @@ Check All + if (vShelfAdd()) {Dopop('/cgi-bin/koha/opac-addbybiblionumber.pl?' + vShelfAdd());} alert('You must be logged in to create or add to Virtual Shelves'); return false;" />

diff --git a/opac/opac-addbybiblionumber.pl b/opac/opac-addbybiblionumber.pl index 4747712d11..2a8c7883a2 100755 --- a/opac/opac-addbybiblionumber.pl +++ b/opac/opac-addbybiblionumber.pl @@ -31,7 +31,7 @@ use C4::Auth; use C4::Output; my $query = new CGI; -my $biblionumber = $query->param('biblionumber'); +my @biblionumber = $query->param('biblionumber'); my $shelfnumber = $query->param('shelfnumber'); my $newvirtualshelf = $query->param('newvirtualshelf'); my $category = $query->param('category'); @@ -45,23 +45,19 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user( } ); -$shelfnumber = AddShelf( '', $newvirtualshelf, $loggedinuser, $category ) if $newvirtualshelf; +$shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category ) if $newvirtualshelf; -# to know if we had to add more than one biblio. -my $multiple = 0; -$multiple = 1 if $biblionumber =~ /^(\d*\/)*$/; - - -if ($shelfnumber) { +# multiple bibs might come in as '/' delimited string (from where, i don't see), or as array. - if ($multiple){ - foreach (split /\//,$biblionumber){ - &AddToShelfFromBiblio($_,$shelfnumber); +my $multiple = 0; +my @bibs; +if (scalar(@biblionumber) == 1) { + @biblionumber = (split /\//,$biblionumber[0]); +} +if ($shelfnumber && ($shelfnumber != -1)) { + for my $bib (@biblionumber){ + &AddToShelfFromBiblio($bib,$shelfnumber); } - } - else { - &AddToShelfFromBiblio( $biblionumber, $shelfnumber ); - } print $query->header; print ""; exit; @@ -87,27 +83,20 @@ else { ); } - if ( $multiple ) { my @biblios; - foreach (split /\//,$biblionumber){ - my $data = GetBiblioData($_); - push @biblios,$data; - } + for my $bib (@biblionumber) { + my $data = GetBiblioData( $bib ); + push(@biblios, + { biblionumber => $bib, + title => $data->{'title'}, + author => $data->{'author'}, + } ); + } $template->param ( - multiple => 1, - biblionumber => $biblionumber, + multiple => (scalar(@biblios) > 1), total => scalar @biblios, biblios => \@biblios, ); - } - else { # just one to add. - my $data = GetBiblioData( $biblionumber ); - $template->param ( - biblionumber => $biblionumber, - title => $data->{'title'}, - author => $data->{'author'}, - ); - } $template->param ( CGIvirtualshelves => $CGIvirtualshelves, -- 2.39.2