*** empty log message ***
[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::Circ2;
64 use C4::Auth;
65 use C4::Interface::CGI::Output;
66
67
68 #use it only to debug !
69 use CGI::Carp qw/fatalsToBrowser/;
70 use warnings;
71
72 my $query = new CGI;
73 my $biblionumber = $query->param('biblionumber');
74 my $shelfnumber = $query->param('shelfnumber');
75 my $newbookshelf = $query->param('newbookshelf');
76 my $category = $query->param('category');
77
78 my ($template, $loggedinuser, $cookie)
79 = get_template_and_user({template_name => "bookshelves/addbookbybiblionumber.tmpl",
80                             query => $query,
81                             type => "intranet",
82                             authnotrequired => 0,
83                             flagsrequired => {catalogue => 1},
84                         });
85
86 $shelfnumber = AddShelf($newbookshelf,$loggedinuser,$category) if $newbookshelf;
87
88 if ($shelfnumber || ($shelfnumber == -1)) { # the shelf already exist.
89     &AddToShelfFromBiblio($biblionumber, $shelfnumber);
90     print "Content-Type: text/html\n\n<html><body onload=\"window.close()\"></body></html>";
91     exit;
92 } else {    # this shelf doesn't already exist.
93     my  ( $bibliocount, @biblios )  = GetBiblio($biblionumber);
94
95     my ($shelflist) = GetShelves($loggedinuser,3);
96     my @shelvesloop;
97     my %shelvesloop;
98     foreach my $element (sort keys %$shelflist) {
99         push (@shelvesloop, $element);
100         $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
101     }
102
103     my $CGIbookshelves=CGI::scrolling_list(
104                 -name     => 'shelfnumber',
105                 -values   => \@shelvesloop,
106                 -labels   => \%shelvesloop,
107                 -size     => 1,
108                 -tabindex=>'',
109                 -multiple => 0 );
110
111     $template->param(
112                 biblionumber => $biblionumber,
113                 title => $biblios[0]->{'title'},
114                 author => $biblios[0]->{'author'},
115                 CGIbookshelves => $CGIbookshelves,
116                 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
117                 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
118                 IntranetNav => C4::Context->preference("IntranetNav"),
119                 );
120
121     output_html_with_http_headers $query, $cookie, $template->output;
122 }
123
124 # $Log$
125 # Revision 1.6  2007/03/09 14:32:26  tipaul
126 # rel_3_0 moved to HEAD
127 #
128 # Revision 1.4.2.6  2006/12/18 16:35:17  toins
129 # removing use HTML::Template from *.pl.
130 #
131 # Revision 1.4.2.5  2006/12/05 11:35:29  toins
132 # Biblio.pm cleaned.
133 # additionalauthors, bibliosubject, bibliosubtitle tables are now unused.
134 # Some functions renamed according to the coding guidelines.
135 #
136 # Revision 1.4.2.4  2006/11/30 18:23:51  toins
137 # theses scripts don't need to use C4::Search.
138 #
139 # Revision 1.4.2.3  2006/10/30 09:48:19  tipaul
140 # samll bugfix to create a bookshelf correctly
141 #
142 # Revision 1.4.2.2  2006/08/30 16:13:54  toins
143 # correct an error in the "if condition".
144 #
145 # Revision 1.4.2.1  2006/08/30 15:59:14  toins
146 # Code cleaned according to coding guide lines.
147 #
148 # Revision 1.4  2006/07/04 14:36:51  toins
149 # Head & rel_2_2 merged
150 #
151 # Revision 1.3.2.4  2006/06/20 16:21:42  oleonard
152 # Adding "tabindex=''" to CGI:scrolling_lists to prevent incorrect tabbing. See Bug 1098
153 #
154 # Revision 1.3.2.3  2006/02/05 21:59:21  kados
155 # Adds script support for IntranetNav ... see mail to koha-devel for
156 # details
157 #
158 # Revision 1.3.2.2  2006/02/05 21:45:25  kados
159 # Adds support for intranetstylesheet system pref in Koha scripts
160 #
161
162 # Local Variables:
163 # tab-width: 4
164 # End: