Finalized XML version for intranet
[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::BookShelves;
29 use C4::Circulation::Circ2;
30 use C4::Auth;
31 use C4::Interface::CGI::Output;
32
33
34 my $env;
35 my $query = new CGI;
36 my $biblionumber = $query->param('biblionumber');
37 my $shelfnumber = $query->param('shelfnumber');
38 my $newbookshelf = $query->param('newbookshelf');
39 my $category = $query->param('category');
40
41 my ($template, $loggedinuser, $cookie)
42 = get_template_and_user({template_name => "bookshelves/addbookbybiblionumber.tmpl",
43                                                         query => $query,
44                                                         type => "intranet",
45                                                         authnotrequired => 0,
46                                                         flagsrequired => {catalogue => 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=CGI::scrolling_list( -name     => 'shelfnumber',
69                                 -values   => \@shelvesloop,
70                                 -labels   => \%shelvesloop,
71                                 -size     => 1,
72                                 -tabindex=>'',
73                                 -multiple => 0 );
74
75         $template->param(biblionumber => $biblionumber,
76                                                 title => $biblios[0]->{'title'},
77                                                 author => $biblios[0]->{'author'},
78                                                 CGIbookshelves => $CGIbookshelves,
79                                                 intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
80                 intranetstylesheet => C4::Context->preference("intranetstylesheet"),
81                 IntranetNav => C4::Context->preference("IntranetNav"),
82                                                 );
83
84         output_html_with_http_headers $query, $cookie, $template->output;
85 }
86 # $Log$
87 # Revision 1.5  2006/09/27 21:19:21  tgarip1957
88 # Finalized XML version for intranet
89 #
90 # Revision 1.4  2006/07/04 14:36:51  toins
91 # Head & rel_2_2 merged
92 #
93 # Revision 1.3.2.4  2006/06/20 16:21:42  oleonard
94 # Adding "tabindex=''" to CGI:scrolling_lists to prevent incorrect tabbing. See Bug 1098
95 #
96 # Revision 1.3.2.3  2006/02/05 21:59:21  kados
97 # Adds script support for IntranetNav ... see mail to koha-devel for
98 # details
99 #
100 # Revision 1.3.2.2  2006/02/05 21:45:25  kados
101 # Adds support for intranetstylesheet system pref in Koha scripts
102 #
103 # Revision 1.3.2.1  2006/02/04 21:26:47  kados
104 # Adds support for intranetcolorstylesheet
105 #
106 # Revision 1.3  2004/12/15 17:28:22  tipaul
107 # adding bookshelf features :
108 # * create bookshelf on the fly
109 # * modify a bookshelf (this being not finished, will commit the rest soon)
110 #
111 # Revision 1.2  2004/11/19 16:31:30  tipaul
112 # bugfix for bookshelves not in official CVS
113 #
114 # Revision 1.1.2.2  2004/03/10 15:08:18  tipaul
115 # modifying shelves : introducing category of shelf : private, public, free for all
116 #
117 # Revision 1.1.2.1  2004/02/19 10:14:36  tipaul
118 # new feature : adding book to bookshelf from biblio detail screen.
119 #
120
121 # Local Variables:
122 # tab-width: 4
123 # End: