Adding hierarchy for hierarchy showing in opac-authoritiesdetail.pl
[koha.git] / bookshelves / addbookbybiblionumber.pl
1 #!/usr/bin/perl
2
3 #script to provide bookshelf management
4 #
5 #
6 # Copyright 2000-2002 Katipo Communications
7 #
8 # This file is part of Koha.
9 #
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
13 # version.
14 #
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.
18 #
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
22
23 # $Id$
24
25 =head1 NAME
26
27     addbookbybiblionumber.pl
28
29 =head1 DESCRIPTION
30
31     This script allow to add a book in a virtual shelf from a biblionumber.
32
33 =head1 CGI PARAMETERS
34
35 =over 4
36
37 =item biblionumber
38
39     The biblionumber
40
41 =item shelfnumber
42
43     the shelfnumber where to add the book.
44
45 =item newbookshelf
46
47     if this parameter exists, then it must be equals to the name of the shelf
48     to add.
49
50 =item category
51
52     if this script has to add a shelf, it add one with this category.
53
54 =back
55
56 =cut
57
58 use strict;
59 use C4::Biblio;
60 use CGI;
61 use C4::Output;
62 use C4::BookShelves;
63 use C4::Circulation;
64 use C4::Auth;
65
66
67 #use it only to debug !
68 use CGI::Carp qw/fatalsToBrowser/;
69 use warnings;
70
71 my $query = new CGI;
72 my $biblionumber = $query->param('biblionumber');
73 my $shelfnumber = $query->param('shelfnumber');
74 my $newbookshelf = $query->param('newbookshelf');
75 my $category = $query->param('category');
76
77 my ($template, $loggedinuser, $cookie)
78 = get_template_and_user({template_name => "bookshelves/addbookbybiblionumber.tmpl",
79                             query => $query,
80                             type => "intranet",
81                             authnotrequired => 0,
82                             flagsrequired => {catalogue => 1},
83                         });
84
85 $shelfnumber = AddShelf($newbookshelf,$loggedinuser,$category) if $newbookshelf;
86
87 if ($shelfnumber || ($shelfnumber == -1)) { # the shelf already exist.
88     &AddToShelfFromBiblio($biblionumber, $shelfnumber);
89     print "Content-Type: text/html\n\n<html><body onload=\"window.close()\"></body></html>";
90     exit;
91 } else {    # this shelf doesn't already exist.
92     my  ( $bibliocount, @biblios )  = GetBiblio($biblionumber);
93
94     my ($shelflist) = GetShelves($loggedinuser,3);
95     my @shelvesloop;
96     my %shelvesloop;
97     foreach my $element (sort keys %$shelflist) {
98         push (@shelvesloop, $element);
99         $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
100     }
101
102     my $CGIbookshelves=CGI::scrolling_list(
103                 -name     => 'shelfnumber',
104                 -values   => \@shelvesloop,
105                 -labels   => \%shelvesloop,
106                 -size     => 1,
107                 -tabindex=>'',
108                 -multiple => 0 );
109
110     $template->param(
111                 biblionumber => $biblionumber,
112                 title => $biblios[0]->{'title'},
113                 author => $biblios[0]->{'author'},
114                 CGIbookshelves => $CGIbookshelves,
115                 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
116                 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
117                 IntranetNav => C4::Context->preference("IntranetNav"),
118                 );
119
120     output_html_with_http_headers $query, $cookie, $template->output;
121 }
122
123 # $Log$
124 # Revision 1.8  2007/04/24 13:54:29  hdl
125 # functions that were in C4::Interface::CGI::Output are now in C4::Output.
126 # So this implies quite a change for files.
127 # Sorry about conflicts which will be caused.
128 # directory Interface::CGI should now be dropped.
129 # I noticed that many scripts (reports ones, but also some circ/stats.pl or opac-topissues) still use Date::Manip.
130 #
131 # Revision 1.7  2007/04/04 16:46:22  tipaul
132 # HUGE COMMIT : code cleaning circulation.
133 #
134 # some stuff to do, i'll write a mail on koha-devel NOW !
135 #
136 # Revision 1.6  2007/03/09 14:32:26  tipaul
137 # rel_3_0 moved to HEAD
138 #
139 # Revision 1.4.2.6  2006/12/18 16:35:17  toins
140 # removing use HTML::Template from *.pl.
141 #
142 # Revision 1.4.2.5  2006/12/05 11:35:29  toins
143 # Biblio.pm cleaned.
144 # additionalauthors, bibliosubject, bibliosubtitle tables are now unused.
145 # Some functions renamed according to the coding guidelines.
146 #
147 # Revision 1.4.2.4  2006/11/30 18:23:51  toins
148 # theses scripts don't need to use C4::Search.
149 #
150 # Revision 1.4.2.3  2006/10/30 09:48:19  tipaul
151 # samll bugfix to create a bookshelf correctly
152 #
153 # Revision 1.4.2.2  2006/08/30 16:13:54  toins
154 # correct an error in the "if condition".
155 #
156 # Revision 1.4.2.1  2006/08/30 15:59:14  toins
157 # Code cleaned according to coding guide lines.
158 #
159 # Revision 1.4  2006/07/04 14:36:51  toins
160 # Head & rel_2_2 merged
161 #
162 # Revision 1.3.2.4  2006/06/20 16:21:42  oleonard
163 # Adding "tabindex=''" to CGI:scrolling_lists to prevent incorrect tabbing. See Bug 1098
164 #
165 # Revision 1.3.2.3  2006/02/05 21:59:21  kados
166 # Adds script support for IntranetNav ... see mail to koha-devel for
167 # details
168 #
169 # Revision 1.3.2.2  2006/02/05 21:45:25  kados
170 # Adds support for intranetstylesheet system pref in Koha scripts
171 #
172
173 # Local Variables:
174 # tab-width: 4
175 # End: