oops, removing un-needed $dbh->commit() calls
[koha.git] / opac / opac-addbybiblionumber.pl
blobc2b719dda03feb9f65bc0e1eab6c2a6791f7b6f6
1 #!/usr/bin/perl
3 #script to provide virtualshelf management
4 # WARNING: This file uses 4-character tabs!
6 # $Header$
8 # Copyright 2000-2002 Katipo Communications
10 # This file is part of Koha.
12 # Koha is free software; you can redistribute it and/or modify it under the
13 # terms of the GNU General Public License as published by the Free Software
14 # Foundation; either version 2 of the License, or (at your option) any later
15 # version.
17 # Koha is distributed in the hope that it will be useful, but WITHOUT ANY
18 # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
19 # A PARTICULAR PURPOSE. See the GNU General Public License for more details.
21 # You should have received a copy of the GNU General Public License along with
22 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
23 # Suite 330, Boston, MA 02111-1307 USA
25 use strict;
26 use C4::Biblio;
27 use CGI;
28 use C4::VirtualShelves;
29 # use C4::Circulation; # not really used
30 use C4::Auth;
31 use C4::Output;
33 my $query = new CGI;
34 my @biblionumber = $query->param('biblionumber');
35 my $selectedshelf = $query->param('selectedshelf');
36 my $newshelf = $query->param('newshelf');
37 my $shelfnumber = $query->param('shelfnumber');
38 my $newvirtualshelf = $query->param('newvirtualshelf');
39 my $category = $query->param('category');
41 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
43 template_name => "opac-addbybiblionumber.tmpl",
44 query => $query,
45 type => "opac",
46 authnotrequired => 1,
50 $shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category ) if $newvirtualshelf;
52 # multiple bibs might come in as '/' delimited string (from where, i don't see), or as array.
54 my $multiple = 0;
55 my @bibs;
56 if (scalar(@biblionumber) == 1) {
57 @biblionumber = (split /\//,$biblionumber[0]);
59 if ($shelfnumber && ($shelfnumber != -1)) {
60 for my $bib (@biblionumber){
61 &AddToShelfFromBiblio($bib,$shelfnumber);
63 print $query->header;
64 print "<html><body onload=\"window.close();\"><div>Please close this window to continue.</div></body></html>";
65 exit;
67 else {
68 if($selectedshelf){
69 # adding to specific shelf
70 my ( $singleshelf, $singleshelfname, $singlecategory ) = GetShelf( $query->param('selectedshelf') );
71 $template->param(
72 singleshelf => 1,
73 shelfnumber => $singleshelf,
74 shelfname => $singleshelfname,
75 "category$singlecategory" => 1
77 } else {
78 # offer choice of shelves
79 my ($shelflist) = GetShelves( $loggedinuser, 3 );
80 my @shelvesloop;
81 my %shelvesloop;
82 foreach my $element ( sort keys %$shelflist ) {
83 push( @shelvesloop, $element );
84 $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
86 my $CGIvirtualshelves;
87 if ( @shelvesloop > 0 ) {
88 $CGIvirtualshelves = CGI::scrolling_list (
89 -name => 'shelfnumber',
90 -values => \@shelvesloop,
91 -labels => \%shelvesloop,
92 -size => 1,
93 -tabindex => '',
94 -multiple => 0
97 $template->param (
98 CGIvirtualshelves => $CGIvirtualshelves,
104 my @biblios;
105 for my $bib (@biblionumber) {
106 my $data = GetBiblioData( $bib );
107 push(@biblios,
108 { biblionumber => $bib,
109 title => $data->{'title'},
110 author => $data->{'author'},
111 } );
113 $template->param (
114 newshelf => $newshelf,
115 multiple => (scalar(@biblios) > 1),
116 total => scalar @biblios,
117 biblios => \@biblios,
120 output_html_with_http_headers $query, $cookie, $template->output;