3 #script to provide virtualshelf management
4 # WARNING: This file uses 4-character tabs!
8 # Copyright 2000-2002 Katipo Communications
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 USA
28 use C4::VirtualShelves qw/:DEFAULT GetRecentShelves RefreshShelvesSummary/;
31 use C4::Auth qw/get_session/;
35 my @biblionumber = $query->param('biblionumber');
36 my $selectedshelf = $query->param('selectedshelf');
37 my $newshelf = $query->param('newshelf');
38 my $shelfnumber = $query->param('shelfnumber');
39 my $newvirtualshelf = $query->param('newvirtualshelf');
40 my $category = $query->param('category');
42 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
44 template_name => "opac-addbybiblionumber.tmpl",
51 if ($newvirtualshelf) {
52 $shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category );
53 RefreshShelvesSummary($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ? 20 : 10));
55 print "<html><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
59 # verify user is authorized to perform the action on the shelf...
62 $authorized = 0 unless ShelfPossibleAction( $loggedinuser, $selectedshelf );
65 # 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 if ($shelfnumber && ($shelfnumber != -1)) {
73 for my $bib (@biblionumber){
74 AddToShelfFromBiblio($bib,$shelfnumber);
76 RefreshShelvesSummary($query->cookie("CGISESSID"),$loggedinuser,($loggedinuser == -1 ? 20 : 10));
78 print "<html><body onload=\"window.opener.location.reload(true);self.close();\"></body></html>";
83 # adding to specific shelf
84 my ( $singleshelf, $singleshelfname, $singlecategory ) = GetShelf( $query->param('selectedshelf') );
87 shelfnumber => $singleshelf,
88 shelfname => $singleshelfname,
89 "category$singlecategory" => 1
92 # offer choice of shelves
93 # first private shelves...
95 my ($shelflist) = GetRecentShelves(1, $limit, $loggedinuser);
98 for my $shelf ( @{${@$shelflist}[0]} ) {
99 push( @shelvesloop, $shelf->{shelfnumber} );
100 $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
102 # then open shelves...
103 my ($shelflist) = GetRecentShelves(3, $limit, undef);
104 for my $shelf ( @{${@$shelflist}[0]} ) {
105 push( @shelvesloop, $shelf->{shelfnumber} );
106 $shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
108 my $CGIvirtualshelves;
109 if ( @shelvesloop > 0 ) {
110 $CGIvirtualshelves = CGI::scrolling_list (
111 -name => 'shelfnumber',
112 -id => 'shelfnumber',
113 -values => \@shelvesloop,
114 -labels => \%shelvesloop,
121 CGIvirtualshelves => $CGIvirtualshelves,
127 for my $bib (@biblionumber) {
128 my $data = GetBiblioData( $bib );
130 { biblionumber => $bib,
131 title => $data->{'title'},
132 author => $data->{'author'},
136 newshelf => $newshelf,
137 multiple => (scalar(@biblios) > 1),
138 total => scalar @biblios,
139 biblios => \@biblios,
140 authorized => $authorized,
143 output_html_with_http_headers $query, $cookie, $template->output;