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/;
65 #use it only to debug !
68 sub AddBibliosToShelf {
69 my ($shelfnumber,@biblionumber)=@_;
71 # multiple bibs might come in as '/' delimited string (from where, i don't see), or as array.
72 if (scalar(@biblionumber) == 1) {
73 @biblionumber = (split /\//,$biblionumber[0]);
75 for my $bib (@biblionumber){
76 AddToShelfFromBiblio($bib, $shelfnumber);
82 # If set, then single item case.
83 my $biblionumber = $query->param('biblionumber');
85 # If set, then multiple item case.
87 my $biblionumbers = $query->param('biblionumbers');
88 my $shelfnumber = $query->param('shelfnumber');
89 my $newvirtualshelf = $query->param('newvirtualshelf');
90 my $category = $query->param('category');
91 my $confirmed = $query->param('confirmed');
92 my $sortfield = $query->param('sortfield');
94 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
96 template_name => "virtualshelves/addbybiblionumber.tmpl",
100 flagsrequired => { catalogue => 1 },
105 if ($biblionumbers) {
106 @biblionumbers = split '/', $biblionumbers;
108 @biblionumbers = (@biblionumber);
111 $shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category, $sortfield )
113 if ( $shelfnumber || ( $shelfnumber == -1 ) ) { # the shelf already exist.
114 if ($confirmed == 1) {
115 AddBibliosToShelf($shelfnumber,@biblionumbers);
117 "Content-Type: text/html\n\n<html><body onload=\"window.opener.location.reload(true);window.close()\"></body></html>";
120 my ( $singleshelf, $singleshelfname, $singlecategory ) = GetShelf( $query->param('shelfnumber') );
122 for my $bib (@biblionumber) {
123 my $data = GetBiblioData( $bib );
125 { biblionumber => $bib,
126 title => $data->{'title'},
127 author => $data->{'author'},
133 biblionumber => \@biblionumber,
134 biblios => \@biblios,
135 multiple => (scalar(@biblionumber) > 1),
137 shelfname => $singleshelfname,
138 shelfnumber => $singleshelf,
139 total => scalar(@biblionumber),
144 else { # this shelf doesn't already exist.
146 my ($shelflist) = GetRecentShelves(1, $limit, $loggedinuser);
149 for my $shelf ( @{ $shelflist->[0] } ) {
150 push( @shelvesloop, $shelf->{shelfnumber} );
151 $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
153 # then open shelves...
154 ($shelflist) = GetRecentShelves(3, $limit, undef);
155 for my $shelf ( @{ $shelflist->[0] } ) {
156 push( @shelvesloop, $shelf->{shelfnumber} );
157 $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
159 if(@shelvesloop gt 0){
160 my $CGIvirtualshelves = CGI::scrolling_list
162 -name => 'shelfnumber',
163 -values => \@shelvesloop,
164 -labels => \%shelvesloop,
171 CGIvirtualshelves => $CGIvirtualshelves,
175 unless ($biblionumbers) {
176 my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
180 biblionumber => $biblionumber,
181 title => $biblios[0]->{'title'},
182 author => $biblios[0]->{'author'},
186 foreach my $biblionumber (@biblionumbers) {
187 my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
189 title=>$biblios[0]->{'title'},
190 author=>$biblios[0]->{'author'}
192 push @biblioloop, \%biblioiter;
196 biblioloop => \@biblioloop,
197 biblionumbers => $biblionumbers
202 output_html_with_http_headers $query, $cookie, $template->output;