adding three new variables for installation:
[koha.git] / opac / opac-addbybiblionumber.pl
1 #!/usr/bin/perl
2
3 #script to provide virtualshelf management
4 # WARNING: This file uses 4-character tabs!
5 #
6 # $Header$
7 #
8 # Copyright 2000-2002 Katipo Communications
9 #
10 # This file is part of Koha.
11 #
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
15 # version.
16 #
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.
20 #
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
24
25 use strict;
26 use C4::Biblio;
27 use CGI;
28 use C4::VirtualShelves;
29 # use C4::Circulation;  # not really used
30 use C4::Auth;
31 use C4::Output;
32
33 my $query        = new CGI;
34 my @biblionumber = $query->param('biblionumber');
35 my $shelfnumber  = $query->param('shelfnumber');
36 my $newvirtualshelf = $query->param('newvirtualshelf');
37 my $category     = $query->param('category');
38
39 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
40     {
41         template_name   => "opac-addbybiblionumber.tmpl",
42         query           => $query,
43         type            => "opac",
44         authnotrequired => 1,
45     }
46 );
47
48 $shelfnumber = AddShelf(  $newvirtualshelf, $loggedinuser, $category ) if $newvirtualshelf;
49
50 # multiple bibs might come in as '/' delimited string (from where, i don't see), or as array.
51
52 my $multiple = 0;
53 my @bibs;
54 if (scalar(@biblionumber) == 1) {
55         @biblionumber =  (split /\//,$biblionumber[0]);
56 }
57 if ($shelfnumber && ($shelfnumber != -1)) {
58         for my $bib (@biblionumber){
59                 &AddToShelfFromBiblio($bib,$shelfnumber);
60         }
61         print $query->header;
62         print "<html><body onload=\"window.close();\"><div>Please close this window to continue.</div></body></html>";
63         exit;
64 }
65 else {
66     my ($shelflist) = GetShelves( $loggedinuser, 3 );
67     my @shelvesloop;
68     my %shelvesloop;
69     foreach my $element ( sort keys %$shelflist ) {
70         push( @shelvesloop, $element );
71                 $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
72     }
73
74     my $CGIvirtualshelves;
75     if ( @shelvesloop > 0 ) {
76         $CGIvirtualshelves = CGI::scrolling_list (
77             -name     => 'shelfnumber',
78             -values   => \@shelvesloop,
79             -labels   => \%shelvesloop,
80             -size     => 1,
81             -tabindex => '',
82             -multiple => 0
83         );
84     }
85
86         my @biblios;
87         for my $bib (@biblionumber) {
88                 my $data = GetBiblioData( $bib );
89                 push(@biblios, 
90                         { biblionumber => $bib,
91                           title        => $data->{'title'},
92                           author       => $data->{'author'},
93                         } );
94         }
95         $template->param (
96                 multiple => (scalar(@biblios) > 1),
97                 total    => scalar @biblios,
98                 biblios  => \@biblios,
99         );
100
101         $template->param (
102                 CGIvirtualshelves       => $CGIvirtualshelves,
103         );
104
105         output_html_with_http_headers $query, $cookie, $template->output;
106 }