fix POD error...
[koha.git] / opac / opac-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 my $newbookshelf = $query->param('newbookshelf');
40 my $category = $query->param('category');
41
42 my ($template, $loggedinuser, $cookie)
43 = get_template_and_user({template_name => "opac-addbookbybiblionumber.tmpl",
44                                                         query => $query,
45                                                         type => "opac",
46                                                         authnotrequired => 1,
47                                                 });
48
49 my $x; # for trash
50 ($x,$x,$shelfnumber) = AddShelf('',$newbookshelf,$loggedinuser,$category) if $newbookshelf;
51
52 if ($shelfnumber) {
53         &AddToShelfFromBiblio($env, $biblionumber, $shelfnumber);
54         print "Content-Type: text/html\n\n<html><body onload=\"window.close()\"></body></html>";
55         exit;
56 } else {
57
58         my  ( $bibliocount, @biblios )  = getbiblio($biblionumber);
59
60         my ($shelflist) = GetShelfList($loggedinuser,3);
61         my @shelvesloop;
62         my %shelvesloop;
63         foreach my $element (sort keys %$shelflist) {
64                         push (@shelvesloop, $element);
65                         $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
66         }
67
68         my $CGIbookshelves;
69         if (@shelvesloop > 0){
70         $CGIbookshelves=CGI::scrolling_list( -name     => 'shelfnumber',
71                                 -values   => \@shelvesloop,
72                                 -labels   => \%shelvesloop,
73                                 -size     => 1,
74                                 -tabindex=>'',
75                                 -multiple => 0 );
76          }
77
78         $template->param(biblionumber => $biblionumber,
79                                 title => $biblios[0]->{'title'},
80                                 author => $biblios[0]->{'author'},
81                                 CGIbookshelves => $CGIbookshelves,
82                                 LibraryName => C4::Context->preference("LibraryName"),
83                                 suggestion => C4::Context->preference("suggestion"),
84                                 virtualshelves => C4::Context->preference("virtualshelves"),
85                                 OpacNav => C4::Context->preference("OpacNav"),
86                                 opaccredits => C4::Context->preference("opaccredits"),
87                                 opacsmallimage => C4::Context->preference("opacsmallimage"),
88                                 opaclayoutstylesheet => C4::Context->preference("opaclayoutstylesheet"),
89                                 opaccolorstylesheet => C4::Context->preference("opaccolorstylesheet"),
90         );
91
92         output_html_with_http_headers $query, $cookie, $template->output;
93 }
94 # $Log$
95 # Revision 1.5  2006/07/04 14:36:52  toins
96 # Head & rel_2_2 merged
97 #
98 # Revision 1.4  2006/05/21 02:10:32  kados
99 # syncing dev-week and HEAD
100 #
101 # Revision 1.1.2.6  2006/04/27 16:23:34  oleonard
102 # Hiding option to add to existing virtual shelves if there are no existing virtual shelves (thanks Chris!)
103 #
104 # Revision 1.1.2.5  2006/03/01 22:33:25  oleonard
105 # Enabling several new system preferences: opacreadinghistory, opaccolorstylesheet, opaclanguagesdisplay, opaclayoutstylesheet, opacsmallimage
106 #
107 # Revision 1.1.2.4  2006/02/04 16:47:21  kados
108 # Adding support for opaccredits to opac scripts
109 #
110 # Revision 1.1.2.3  2006/02/03 21:03:57  kados
111 # Updating script for new system preference: OpacNav
112 # ----------------------------------------------------------------------
113 #
114 # Revision 1.1.2.2  2005/03/25 17:04:27  tipaul
115 # adding virtual shelves & suggestions button to the top
116 #
117 # Revision 1.1.2.1  2005/03/10 08:44:43  tipaul
118 # bugfix in baskets :
119 # * The user does not need to have to have librarian rights to use virtual shelves
120 # * error when adding a biblio to an existing basket
121 #
122 # Revision 1.1  2005/01/03 11:09:59  tipaul
123 # *** empty log message ***
124 #
125
126 # Local Variables:
127 # tab-width: 4
128 # End: