3 #script to provide virtual shelf management
6 # Copyright 2000-2002 Katipo Communications
8 # This file is part of Koha.
10 # Koha is free software; you can redistribute it and/or modify it under the
11 # terms of the GNU General Public License as published by the Free Software
12 # Foundation; either version 2 of the License, or (at your option) any later
15 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
16 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
17 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19 # You should have received a copy of the GNU General Public License along with
20 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
21 # Suite 330, Boston, MA 02111-1307 USA
30 This script allow to add a virtual in a virtual shelf from a biblionumber.
42 the shelfnumber where to add the virtual.
46 if this parameter exists, then it must be equals to the name of the shelf
51 if this script has to add a shelf, it add one with this category.
61 use C4::VirtualShelves qw/:DEFAULT GetRecentShelves/;
64 #splits incoming biblionumber(s) to array and adds each to shelf.
65 sub AddBibliosToShelf {
66 my ($shelfnumber,@biblionumber)=@_;
68 # multiple bibs might come in as '/' delimited string (from where, i don't see), or as array.
69 if (scalar(@biblionumber) == 1) {
70 @biblionumber = (split /\//,$biblionumber[0]);
72 for my $bib (@biblionumber){
73 AddToShelfFromBiblio($bib, $shelfnumber);
79 #use it only to debug !
80 use CGI::Carp qw/fatalsToBrowser/;
85 # If set, then single item case.
86 my $biblionumber = $query->param('biblionumber');
88 # If set, then multiple item case.
89 my @biblionumber = $query->param('biblionumber');
90 my $biblionumbers = $query->param('biblionumbers');
92 my $shelfnumber = $query->param('shelfnumber');
93 my $newvirtualshelf = $query->param('newvirtualshelf');
94 my $category = $query->param('category');
95 my $sortfield = $query->param('sortfield');
96 my $confirmed = $query->param('confirmed') || 0;
99 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
101 template_name => "virtualshelves/addbybiblionumber.tmpl",
104 authnotrequired => 0,
105 flagsrequired => { catalogue => 1 },
110 if ($biblionumbers) {
111 @biblionumbers = split '/', $biblionumbers;
113 @biblionumbers = ($biblionumber);
116 $shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category, $sortfield )
118 if ( $shelfnumber || ( $shelfnumber == -1 ) ) { # the shelf already exist.
120 if ($confirmed == 1) {
121 AddBibliosToShelf($shelfnumber,@biblionumber);
123 "Content-Type: text/html\n\n<html><body onload=\"window.opener.location.reload(true);window.close()\"></body></html>";
126 my ( $singleshelf, $singleshelfname, $singlecategory ) = GetShelf( $query->param('shelfnumber') );
128 for my $bib (@biblionumber) {
129 my $data = GetBiblioData( $bib );
131 { biblionumber => $bib,
132 title => $data->{'title'},
133 author => $data->{'author'},
139 biblionumber => \@biblionumber,
140 biblios => \@biblios,
141 multiple => (scalar(@biblionumber) > 1),
143 shelfname => $singleshelfname,
144 shelfnumber => $singleshelf,
145 total => scalar(@biblionumber),
150 else { # this shelf doesn't already exist.
152 my ($shelflist) = GetRecentShelves(1, $limit, $loggedinuser);
155 for my $shelf ( @{ $shelflist->[0] } ) {
156 push( @shelvesloop, $shelf->{shelfnumber} );
157 $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
159 # then open shelves...
160 my ($shelflist) = GetRecentShelves(3, $limit, undef);
161 for my $shelf ( @{ $shelflist->[0] } ) {
162 push( @shelvesloop, $shelf->{shelfnumber} );
163 $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
165 if(@shelvesloop gt 0){
166 my $CGIvirtualshelves = CGI::scrolling_list
168 -name => 'shelfnumber',
169 -values => \@shelvesloop,
170 -labels => \%shelvesloop,
177 CGIvirtualshelves => $CGIvirtualshelves,
181 unless ($biblionumbers) {
182 my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
186 biblionumber => $biblionumber,
187 title => $biblios[0]->{'title'},
188 author => $biblios[0]->{'author'},
192 foreach my $biblionumber (@biblionumbers) {
193 my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
195 title=>$biblios[0]->{'title'},
196 author=>$biblios[0]->{'author'}
198 push @biblioloop, \%biblioiter;
202 biblioloop => \@biblioloop,
203 biblionumbers => $biblionumbers
209 output_html_with_http_headers $query, $cookie, $template->output;