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 !
82 sub AddBibliosToShelf {
83 my ($shelfnumber,@biblionumber)=@_;
85 # multiple bibs might come in as '/' delimited string (from where, i don't see), or as array.
86 if (scalar(@biblionumber) == 1) {
87 @biblionumber = (split /\//,$biblionumber[0]);
89 for my $bib (@biblionumber){
90 AddToShelfFromBiblio($bib, $shelfnumber);
96 # If set, then single item case.
97 my $biblionumber = $query->param('biblionumber');
99 # If set, then multiple item case.
100 my @biblionumber = $query->param('biblionumber');
101 my $biblionumbers = $query->param('biblionumbers');
103 my $shelfnumber = $query->param('shelfnumber');
104 my $newvirtualshelf = $query->param('newvirtualshelf');
105 my $category = $query->param('category');
106 my $sortfield = $query->param('sortfield');
107 my $confirmed = $query->param('confirmed') || 0;
110 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
112 template_name => "virtualshelves/addbybiblionumber.tmpl",
115 authnotrequired => 0,
116 flagsrequired => { catalogue => 1 },
121 if ($biblionumbers) {
122 @biblionumbers = split '/', $biblionumbers;
124 @biblionumbers = (@biblionumber);
127 $shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category, $sortfield )
129 if ( $shelfnumber || ( $shelfnumber == -1 ) ) { # the shelf already exist.
131 if ($confirmed == 1) {
132 AddBibliosToShelf($shelfnumber,@biblionumber);
134 "Content-Type: text/html\n\n<html><body onload=\"window.opener.location.reload(true);window.close()\"></body></html>";
137 my ( $singleshelf, $singleshelfname, $singlecategory ) = GetShelf( $query->param('shelfnumber') );
139 for my $bib (@biblionumber) {
140 my $data = GetBiblioData( $bib );
142 { biblionumber => $bib,
143 title => $data->{'title'},
144 author => $data->{'author'},
150 biblionumber => \@biblionumber,
151 biblios => \@biblios,
152 multiple => (scalar(@biblionumber) > 1),
154 shelfname => $singleshelfname,
155 shelfnumber => $singleshelf,
156 total => scalar(@biblionumber),
161 else { # this shelf doesn't already exist.
163 my ($shelflist) = GetRecentShelves(1, $limit, $loggedinuser);
166 for my $shelf ( @{ $shelflist->[0] } ) {
167 push( @shelvesloop, $shelf->{shelfnumber} );
168 $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
170 # then open shelves...
171 ($shelflist) = GetRecentShelves(3, $limit, undef);
172 for my $shelf ( @{ $shelflist->[0] } ) {
173 push( @shelvesloop, $shelf->{shelfnumber} );
174 $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
176 if(@shelvesloop gt 0){
177 my $CGIvirtualshelves = CGI::scrolling_list
179 -name => 'shelfnumber',
180 -values => \@shelvesloop,
181 -labels => \%shelvesloop,
188 CGIvirtualshelves => $CGIvirtualshelves,
192 unless ($biblionumbers) {
193 my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
197 biblionumber => $biblionumber,
198 title => $biblios[0]->{'title'},
199 author => $biblios[0]->{'author'},
203 foreach my $biblionumber (@biblionumbers) {
204 my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
206 title=>$biblios[0]->{'title'},
207 author=>$biblios[0]->{'author'}
209 push @biblioloop, \%biblioiter;
213 biblioloop => \@biblioloop,
214 biblionumbers => $biblionumbers
219 output_html_with_http_headers $query, $cookie, $template->output;