bugfix for bookshelves not in official CVS
[koha.git] / bookshelves / addbookbybiblionumber.pl
1 #!/usr/bin/perl
2 #script to provide bookshelf management
3 # WARNING: This file uses 4-character tabs!
4 #
5 # $Header$
6 #
7 # Copyright 2000-2002 Katipo Communications
8 #
9 # This file is part of Koha.
10 #
11 # Koha is free software; you can redistribute it and/or modify it under the
12 # terms of the GNU General Public License as published by the Free Software
13 # Foundation; either version 2 of the License, or (at your option) any later
14 # version.
15 #
16 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
17 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
18 # A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License along with
21 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
22 # Suite 330, Boston, MA  02111-1307 USA
23
24 use strict;
25 use C4::Search;
26 use C4::Biblio;
27 use CGI;
28 use C4::Output;
29 use C4::BookShelves;
30 use C4::Circulation::Circ2;
31 use C4::Auth;
32 use C4::Interface::CGI::Output;
33 use HTML::Template;
34
35 my $env;
36 my $query = new CGI;
37 my $biblionumber = $query->param('biblionumber');
38 my $shelfnumber = $query->param('shelfnumber');
39 if ($shelfnumber) {
40         &AddToShelfFromBiblio($env, $biblionumber, $shelfnumber);
41         print "Content-Type: text/html\n\n<html><body onload=\"window.close()\"></body></html>";
42         exit;
43 } else {
44
45         my  ( $bibliocount, @biblios )  = getbiblio($biblionumber);
46         my ($template, $loggedinuser, $cookie)
47         = get_template_and_user({template_name => "bookshelves/addbookbybiblionumber.tmpl",
48                                                                 query => $query,
49                                                                 type => "intranet",
50                                                                 authnotrequired => 0,
51                                                                 flagsrequired => {catalogue => 1},
52                                                         });
53
54         my ($shelflist) = GetShelfList($loggedinuser,3);
55         my @shelvesloop;
56         my %shelvesloop;
57         foreach my $element (sort keys %$shelflist) {
58                         push (@shelvesloop, $element);
59                         $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
60         }
61
62         my $CGIbookshelves=CGI::scrolling_list( -name     => 'shelfnumber',
63                                 -values   => \@shelvesloop,
64                                 -labels   => \%shelvesloop,
65                                 -size     => 1,
66                                 -multiple => 0 );
67
68         $template->param(biblionumber => $biblionumber,
69                                                 title => $biblios[0]->{'title'},
70                                                 author => $biblios[0]->{'author'},
71                                                 CGIbookshelves => $CGIbookshelves,
72                                                 );
73
74         output_html_with_http_headers $query, $cookie, $template->output;
75 }
76 # $Log$
77 # Revision 1.2  2004/11/19 16:31:30  tipaul
78 # bugfix for bookshelves not in official CVS
79 #
80 # Revision 1.1.2.2  2004/03/10 15:08:18  tipaul
81 # modifying shelves : introducing category of shelf : private, public, free for all
82 #
83 # Revision 1.1.2.1  2004/02/19 10:14:36  tipaul
84 # new feature : adding book to bookshelf from biblio detail screen.
85 #
86
87 # Local Variables:
88 # tab-width: 4
89 # End: