+++ /dev/null
-# -*- tab-width: 8 -*-
-# Please use 8-character tabs for this file (indents are every 4 characters)
-
-package C4::BookShelves;
-
-# $Id$
-
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
-
-use strict;
-require Exporter;
-use C4::Context;
-use C4::Circulation;
-use vars qw($VERSION @ISA @EXPORT);
-
-# set the version for version checking
-$VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
-
-=head1 NAME
-
-C4::BookShelves - Functions for manipulating Koha virtual bookshelves
-
-=head1 SYNOPSIS
-
- use C4::BookShelves;
-
-=head1 DESCRIPTION
-
-This module provides functions for manipulating virtual bookshelves,
-including creating and deleting bookshelves, and adding and removing
-items to and from bookshelves.
-
-=head1 FUNCTIONS
-
-=over 2
-
-=cut
-
-@ISA = qw(Exporter);
-@EXPORT = qw(
- &GetShelves &GetShelfContents &GetShelf
-
- &AddToShelf &AddToShelfFromBiblio &AddShelf
-
- &ModShelf
- &ShelfPossibleAction
- &DelFromShelf &DelShelf
-);
-
-my $dbh = C4::Context->dbh;
-
-=item GetShelves
-
- $shelflist = &GetShelves($owner, $mincategory);
- ($shelfnumber, $shelfhash) = each %{$shelflist};
-
-Looks up the virtual bookshelves, and returns a summary. C<$shelflist>
-is a reference-to-hash. The keys are the bookshelf numbers
-(C<$shelfnumber>, above), and the values (C<$shelfhash>, above) are
-themselves references-to-hash, with the following keys:
-
-C<mincategory> : 2 if the list is for "look". 3 if the list is for "Select bookshelf for adding a book".
-bookshelves of the owner are always selected, whatever the category
-
-=over 4
-
-=item C<$shelfhash-E<gt>{shelfname}>
-
-A string. The name of the shelf.
-
-=item C<$shelfhash-E<gt>{count}>
-
-The number of books on that bookshelf.
-
-=back
-
-=cut
-
-#'
-# FIXME - Wouldn't it be more intuitive to return a list, rather than
-# a reference-to-hash? The shelf number can be just another key in the
-# hash.
-
-sub GetShelves {
- my ( $owner, $mincategory ) = @_;
-
- my $query = qq(
- SELECT bookshelf.shelfnumber, bookshelf.shelfname,owner,surname,firstname,bookshelf.category,
- count(shelfcontents.itemnumber) as count
- FROM bookshelf
- LEFT JOIN shelfcontents ON bookshelf.shelfnumber = shelfcontents.shelfnumber
- LEFT JOIN borrowers ON bookshelf.owner = borrowers.borrowernumber
- WHERE owner=? OR category>=?
- GROUP BY bookshelf.shelfnumber
- ORDER BY bookshelf.category, bookshelf.shelfname, borrowers.firstname, borrowers.surname
- );
- my $sth = $dbh->prepare($query);
- $sth->execute( $owner, $mincategory );
- my %shelflist;
- while (
- my (
- $shelfnumber, $shelfname, $owner, $surname,
- $firstname, $category, $count
- )
- = $sth->fetchrow
- )
- {
- $shelflist{$shelfnumber}->{'shelfname'} = $shelfname;
- $shelflist{$shelfnumber}->{'count'} = $count;
- $shelflist{$shelfnumber}->{'category'} = $category;
- $shelflist{$shelfnumber}->{'owner'} = $owner;
- $shelflist{$shelfnumber}->{'surname'} = $surname;
- $shelflist{$shelfnumber}->{'firstname'} = $firstname;
- }
- return ( \%shelflist );
-}
-
-=item GetShef
-
- (shelfnumber,shelfname,owner,category) = &GetShelf($shelfnumber);
-
-Looks up information about the contents of virtual bookshelf number
-C<$shelfnumber>
-
-Returns the database's information on 'bookshelf' table.
-
-=cut
-
-sub GetShelf {
- my ($shelfnumber) = @_;
- my $query = qq(
- SELECT shelfnumber,shelfname,owner,category
- FROM bookshelf
- WHERE shelfnumber=?
- );
- my $sth = $dbh->prepare($query);
- $sth->execute($shelfnumber);
- return $sth->fetchrow;
-}
-
-=item GetShelfContents
-
- $itemlist = &GetShelfContents($shelfnumber);
-
-Looks up information about the contents of virtual bookshelf number
-C<$shelfnumber>.
-
-Returns a reference-to-array, whose elements are references-to-hash,
-as returned by C<C4::Biblio::GetBiblioFromItemNumber>.
-
-=cut
-
-#'
-sub GetShelfContents {
- my ( $shelfnumber ) = @_;
- my @itemlist;
- my $query =
- " SELECT itemnumber
- FROM shelfcontents
- WHERE shelfnumber=?
- ORDER BY itemnumber
- ";
- my $sth = $dbh->prepare($query);
- $sth->execute($shelfnumber);
- my $sth2 = $dbh->prepare("
- SELECT biblio.*,biblioitems.* FROM items
- LEFT JOIN biblio on items.biblionumber=biblio.biblionumber
- LEFT JOIN biblioitems on items.biblionumber=biblioitems.biblionumber
- WHERE items.itemnumber=?"
- );
- while ( my ($itemnumber) = $sth->fetchrow ) {
- $sth2->execute($itemnumber);
- my $item = $sth2->fetchrow_hashref;
- $item->{'itemnumber'}=$itemnumber;
- push( @itemlist, $item );
- }
- return ( \@itemlist );
-}
-
-=item AddShelf
-
- $shelfnumber = &AddShelf( $shelfname, $owner, $category);
-
-Creates a new virtual bookshelf with name C<$shelfname>, owner C<$owner> and category
-C<$category>.
-
-Returns a code to know what's happen.
- * -1 : if this bookshelf already exist.
- * $shelfnumber : if success.
-
-=cut
-
-sub AddShelf {
- my ( $shelfname, $owner, $category ) = @_;
- my $query = qq(
- SELECT *
- FROM bookshelf
- WHERE shelfname=? AND owner=?
- );
- my $sth = $dbh->prepare($query);
- $sth->execute($shelfname,$owner);
- if ( $sth->rows ) {
- return (-1);
- }
- else {
- my $query = qq(
- INSERT INTO bookshelf
- (shelfname,owner,category)
- VALUES (?,?,?)
- );
- $sth = $dbh->prepare($query);
- $sth->execute( $shelfname, $owner, $category );
- my $shelfnumber = $dbh->{'mysql_insertid'};
- return ($shelfnumber);
- }
-}
-
-=item AddToShelf
-
- &AddToShelf($itemnumber, $shelfnumber);
-
-Adds item number C<$itemnumber> to virtual bookshelf number
-C<$shelfnumber>, unless that item is already on that shelf.
-
-=cut
-
-#'
-sub AddToShelf {
- my ( $itemnumber, $shelfnumber ) = @_;
- return unless $itemnumber;
- my $query = qq(
- SELECT *
- FROM shelfcontents
- WHERE shelfnumber=? AND itemnumber=?
- );
- my $sth = $dbh->prepare($query);
-
- $sth->execute( $shelfnumber, $itemnumber );
- unless ( $sth->rows ) {
- # already on shelf
- my $query = qq(
- INSERT INTO shelfcontents
- (shelfnumber, itemnumber, flags)
- VALUES
- (?, ?, 0)
- );
- $sth = $dbh->prepare($query);
- $sth->execute( $shelfnumber, $itemnumber );
- }
-}
-
-=item AddToShelfFromBiblio
-
- &AddToShelfFromBiblio($biblionumber, $shelfnumber)
-
- this function allow to add a book into the shelf number $shelfnumber
- from biblionumber.
-
-=cut
-
-sub AddToShelfFromBiblio {
- my ( $biblionumber, $shelfnumber ) = @_;
- return unless $biblionumber;
- my $query = qq(
- SELECT itemnumber
- FROM items
- WHERE biblionumber=?
- );
- my $sth = $dbh->prepare($query);
- $sth->execute($biblionumber);
- my ($itemnumber) = $sth->fetchrow;
- $query = qq(
- SELECT *
- FROM shelfcontents
- WHERE shelfnumber=? AND itemnumber=?
- );
- $sth = $dbh->prepare($query);
- $sth->execute( $shelfnumber, $itemnumber );
- unless ( $sth->rows ) {
- # "already on shelf";
- my $query =qq(
- INSERT INTO shelfcontents
- (shelfnumber, itemnumber, flags)
- VALUES
- (?, ?, 0)
- );
- $sth = $dbh->prepare($query);
- $sth->execute( $shelfnumber, $itemnumber );
- }
-}
-
-=item ModShelf
-
-ModShelf($shelfnumber, $shelfname, $owner, $category )
-
-Modify the value into bookshelf table with values given on input arg.
-
-=cut
-
-sub ModShelf {
- my ( $shelfnumber, $shelfname, $owner, $category ) = @_;
- my $query = qq(
- UPDATE bookshelf
- SET shelfname=?,owner=?,category=?
- WHERE shelfnumber=?
- );
- my $sth = $dbh->prepare($query);
- $sth->execute( $shelfname, $owner, $category, $shelfnumber );
-}
-
-=item DelShelf
-
- ($status) = &DelShelf($shelfnumber);
-
-Deletes virtual bookshelf number C<$shelfnumber>. The bookshelf must
-be empty.
-
-Returns a two-element array, where C<$status> is 0 if the operation
-was successful, or non-zero otherwise. C<$msg> is "Done" in case of
-success, or an error message giving the reason for failure.
-
-=cut
-
-
-=item ShelfPossibleAction
-
-ShelfPossibleAction($loggedinuser, $shelfnumber, $action);
-
-C<$loggedinuser,$shelfnumber,$action>
-
-$action can be "view" or "manage".
-
-Returns 1 if the user can do the $action in the $shelfnumber shelf.
-Returns 0 otherwise.
-
-=cut
-
-sub ShelfPossibleAction {
- my ( $user, $shelfnumber, $action ) = @_;
- my $query = qq(
- SELECT owner,category
- FROM bookshelf
- WHERE shelfnumber=?
- );
- my $sth = $dbh->prepare($query);
- $sth->execute($shelfnumber);
- my ( $owner, $category ) = $sth->fetchrow;
- return 1 if (($category >= 3 or $owner eq $user) && $action eq 'manage' );
- return 1 if (($category >= 2 or $owner eq $user) && $action eq 'view' );
- return 0;
-}
-
-=item DelFromShelf
-
- &DelFromShelf( $itemnumber, $shelfnumber);
-
-Removes item number C<$itemnumber> from virtual bookshelf number
-C<$shelfnumber>. If the item wasn't on that bookshelf to begin with,
-nothing happens.
-
-=cut
-
-#'
-sub DelFromShelf {
- my ( $itemnumber, $shelfnumber ) = @_;
- my $query = qq(
- DELETE FROM shelfcontents
- WHERE shelfnumber=? AND itemnumber=?
- );
- my $sth = $dbh->prepare($query);
- $sth->execute( $shelfnumber, $itemnumber );
-}
-
-=head2 DelShelf
-
- $Number = DelShelf($shelfnumber);
-
- this function delete the shelf number, and all of it's content
-
-=cut
-
-#'
-sub DelShelf {
- my ( $shelfnumber ) = @_;
- my $sth = $dbh->prepare("DELETE FROM bookshelf WHERE shelfnumber=?");
- $sth->execute($shelfnumber);
- return 0;
-}
-
-END { } # module clean-up code here (global destructor)
-
-1;
-
-__END__
-
-=back
-
-=head1 AUTHOR
-
-Koha Developement team <info@koha.org>
-
-=head1 SEE ALSO
-
-C4::Circulation::Circ2(3)
-
-=cut
-
-#
-# $Log$
-# Revision 1.21 2007/04/04 16:46:22 tipaul
-# HUGE COMMIT : code cleaning circulation.
-#
-# some stuff to do, i'll write a mail on koha-devel NOW !
-#
-# Revision 1.20 2007/03/09 14:31:47 tipaul
-# rel_3_0 moved to HEAD
-#
-# Revision 1.15.8.10 2007/01/25 13:18:15 tipaul
-# checking that a bookshelf with the same name AND OWNER does not exist before creating it
-#
-# Revision 1.15.8.9 2006/12/15 17:37:52 toins
-# removing a function used only once.
-#
-# Revision 1.15.8.8 2006/12/14 17:22:55 toins
-# bookshelves work perfectly with mod_perl and are cleaned.
-#
-# Revision 1.15.8.7 2006/12/13 19:46:41 hdl
-# Some bug fixing.
-#
-# Revision 1.15.8.6 2006/12/11 17:10:06 toins
-# fixing some bugs on bookshelves.
-#
-# Revision 1.15.8.5 2006/12/07 16:45:43 toins
-# removing warn compilation. (perl -wc)
-#
-# Revision 1.15.8.4 2006/11/23 09:05:01 tipaul
-# enable removal of a bookshelf even if there are items inside
-#
-# Revision 1.15.8.3 2006/10/30 09:50:20 tipaul
-# removing getiteminformations (using direct SQL, as we are in a .pm, so it's "legal")
-#
-# Revision 1.15.8.2 2006/08/31 16:03:52 toins
-# Add Pod to DelShelf
-#
-# Revision 1.15.8.1 2006/08/30 15:59:14 toins
-# Code cleaned according to coding guide lines.
-#
-# Revision 1.15 2004/12/16 11:30:58 tipaul
-# adding bookshelf features :
-# * create bookshelf on the fly
-# * modify a bookshelf name & status
-#
-# Revision 1.14 2004/12/15 17:28:23 tipaul
-# adding bookshelf features :
-# * create bookshelf on the fly
-# * modify a bookshelf (this being not finished, will commit the rest soon)
--- /dev/null
+# -*- tab-width: 8 -*-
+# Please use 8-character tabs for this file (indents are every 4 characters)
+
+package C4::BookShelves;
+
+# $Id$
+
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+require Exporter;
+use C4::Context;
+use C4::Circulation;
+use vars qw($VERSION @ISA @EXPORT);
+
+# set the version for version checking
+$VERSION = do { my @v = '$Revision$' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
+
+=head1 NAME
+
+C4::BookShelves - Functions for manipulating Koha virtual bookshelves
+
+=head1 SYNOPSIS
+
+ use C4::BookShelves;
+
+=head1 DESCRIPTION
+
+This module provides functions for manipulating virtual bookshelves,
+including creating and deleting bookshelves, and adding and removing
+items to and from bookshelves.
+
+=head1 FUNCTIONS
+
+=over 2
+
+=cut
+
+@ISA = qw(Exporter);
+@EXPORT = qw(
+ &GetShelves &GetShelfContents &GetShelf
+
+ &AddToShelf &AddToShelfFromBiblio &AddShelf
+
+ &ModShelf
+ &ShelfPossibleAction
+ &DelFromShelf &DelShelf
+);
+
+my $dbh = C4::Context->dbh;
+
+=item GetShelves
+
+ $shelflist = &GetShelves($owner, $mincategory);
+ ($shelfnumber, $shelfhash) = each %{$shelflist};
+
+Looks up the virtual bookshelves, and returns a summary. C<$shelflist>
+is a reference-to-hash. The keys are the bookshelf numbers
+(C<$shelfnumber>, above), and the values (C<$shelfhash>, above) are
+themselves references-to-hash, with the following keys:
+
+C<mincategory> : 2 if the list is for "look". 3 if the list is for "Select bookshelf for adding a book".
+bookshelves of the owner are always selected, whatever the category
+
+=over 4
+
+=item C<$shelfhash-E<gt>{shelfname}>
+
+A string. The name of the shelf.
+
+=item C<$shelfhash-E<gt>{count}>
+
+The number of books on that bookshelf.
+
+=back
+
+=cut
+
+#'
+# FIXME - Wouldn't it be more intuitive to return a list, rather than
+# a reference-to-hash? The shelf number can be just another key in the
+# hash.
+
+sub GetShelves {
+ my ( $owner, $mincategory ) = @_;
+
+ my $query = qq(
+ SELECT bookshelf.shelfnumber, bookshelf.shelfname,owner,surname,firstname,bookshelf.category,
+ count(shelfcontents.itemnumber) as count
+ FROM bookshelf
+ LEFT JOIN shelfcontents ON bookshelf.shelfnumber = shelfcontents.shelfnumber
+ LEFT JOIN borrowers ON bookshelf.owner = borrowers.borrowernumber
+ WHERE owner=? OR category>=?
+ GROUP BY bookshelf.shelfnumber
+ ORDER BY bookshelf.category, bookshelf.shelfname, borrowers.firstname, borrowers.surname
+ );
+ my $sth = $dbh->prepare($query);
+ $sth->execute( $owner, $mincategory );
+ my %shelflist;
+ while (
+ my (
+ $shelfnumber, $shelfname, $owner, $surname,
+ $firstname, $category, $count
+ )
+ = $sth->fetchrow
+ )
+ {
+ $shelflist{$shelfnumber}->{'shelfname'} = $shelfname;
+ $shelflist{$shelfnumber}->{'count'} = $count;
+ $shelflist{$shelfnumber}->{'category'} = $category;
+ $shelflist{$shelfnumber}->{'owner'} = $owner;
+ $shelflist{$shelfnumber}->{'surname'} = $surname;
+ $shelflist{$shelfnumber}->{'firstname'} = $firstname;
+ }
+ return ( \%shelflist );
+}
+
+=item GetShef
+
+ (shelfnumber,shelfname,owner,category) = &GetShelf($shelfnumber);
+
+Looks up information about the contents of virtual bookshelf number
+C<$shelfnumber>
+
+Returns the database's information on 'bookshelf' table.
+
+=cut
+
+sub GetShelf {
+ my ($shelfnumber) = @_;
+ my $query = qq(
+ SELECT shelfnumber,shelfname,owner,category
+ FROM bookshelf
+ WHERE shelfnumber=?
+ );
+ my $sth = $dbh->prepare($query);
+ $sth->execute($shelfnumber);
+ return $sth->fetchrow;
+}
+
+=item GetShelfContents
+
+ $itemlist = &GetShelfContents($shelfnumber);
+
+Looks up information about the contents of virtual bookshelf number
+C<$shelfnumber>.
+
+Returns a reference-to-array, whose elements are references-to-hash,
+as returned by C<C4::Biblio::GetBiblioFromItemNumber>.
+
+=cut
+
+#'
+sub GetShelfContents {
+ my ( $shelfnumber ) = @_;
+ my @itemlist;
+ my $query =
+ " SELECT itemnumber
+ FROM shelfcontents
+ WHERE shelfnumber=?
+ ORDER BY itemnumber
+ ";
+ my $sth = $dbh->prepare($query);
+ $sth->execute($shelfnumber);
+ my $sth2 = $dbh->prepare("
+ SELECT biblio.*,biblioitems.* FROM items
+ LEFT JOIN biblio on items.biblionumber=biblio.biblionumber
+ LEFT JOIN biblioitems on items.biblionumber=biblioitems.biblionumber
+ WHERE items.itemnumber=?"
+ );
+ while ( my ($itemnumber) = $sth->fetchrow ) {
+ $sth2->execute($itemnumber);
+ my $item = $sth2->fetchrow_hashref;
+ $item->{'itemnumber'}=$itemnumber;
+ push( @itemlist, $item );
+ }
+ return ( \@itemlist );
+}
+
+=item AddShelf
+
+ $shelfnumber = &AddShelf( $shelfname, $owner, $category);
+
+Creates a new virtual bookshelf with name C<$shelfname>, owner C<$owner> and category
+C<$category>.
+
+Returns a code to know what's happen.
+ * -1 : if this bookshelf already exist.
+ * $shelfnumber : if success.
+
+=cut
+
+sub AddShelf {
+ my ( $shelfname, $owner, $category ) = @_;
+ my $query = qq(
+ SELECT *
+ FROM bookshelf
+ WHERE shelfname=? AND owner=?
+ );
+ my $sth = $dbh->prepare($query);
+ $sth->execute($shelfname,$owner);
+ if ( $sth->rows ) {
+ return (-1);
+ }
+ else {
+ my $query = qq(
+ INSERT INTO bookshelf
+ (shelfname,owner,category)
+ VALUES (?,?,?)
+ );
+ $sth = $dbh->prepare($query);
+ $sth->execute( $shelfname, $owner, $category );
+ my $shelfnumber = $dbh->{'mysql_insertid'};
+ return ($shelfnumber);
+ }
+}
+
+=item AddToShelf
+
+ &AddToShelf($itemnumber, $shelfnumber);
+
+Adds item number C<$itemnumber> to virtual bookshelf number
+C<$shelfnumber>, unless that item is already on that shelf.
+
+=cut
+
+#'
+sub AddToShelf {
+ my ( $itemnumber, $shelfnumber ) = @_;
+ return unless $itemnumber;
+ my $query = qq(
+ SELECT *
+ FROM shelfcontents
+ WHERE shelfnumber=? AND itemnumber=?
+ );
+ my $sth = $dbh->prepare($query);
+
+ $sth->execute( $shelfnumber, $itemnumber );
+ unless ( $sth->rows ) {
+ # already on shelf
+ my $query = qq(
+ INSERT INTO shelfcontents
+ (shelfnumber, itemnumber, flags)
+ VALUES
+ (?, ?, 0)
+ );
+ $sth = $dbh->prepare($query);
+ $sth->execute( $shelfnumber, $itemnumber );
+ }
+}
+
+=item AddToShelfFromBiblio
+
+ &AddToShelfFromBiblio($biblionumber, $shelfnumber)
+
+ this function allow to add a book into the shelf number $shelfnumber
+ from biblionumber.
+
+=cut
+
+sub AddToShelfFromBiblio {
+ my ( $biblionumber, $shelfnumber ) = @_;
+ return unless $biblionumber;
+ my $query = qq(
+ SELECT itemnumber
+ FROM items
+ WHERE biblionumber=?
+ );
+ my $sth = $dbh->prepare($query);
+ $sth->execute($biblionumber);
+ my ($itemnumber) = $sth->fetchrow;
+ $query = qq(
+ SELECT *
+ FROM shelfcontents
+ WHERE shelfnumber=? AND itemnumber=?
+ );
+ $sth = $dbh->prepare($query);
+ $sth->execute( $shelfnumber, $itemnumber );
+ unless ( $sth->rows ) {
+ # "already on shelf";
+ my $query =qq(
+ INSERT INTO shelfcontents
+ (shelfnumber, itemnumber, flags)
+ VALUES
+ (?, ?, 0)
+ );
+ $sth = $dbh->prepare($query);
+ $sth->execute( $shelfnumber, $itemnumber );
+ }
+}
+
+=item ModShelf
+
+ModShelf($shelfnumber, $shelfname, $owner, $category )
+
+Modify the value into bookshelf table with values given on input arg.
+
+=cut
+
+sub ModShelf {
+ my ( $shelfnumber, $shelfname, $owner, $category ) = @_;
+ my $query = qq(
+ UPDATE bookshelf
+ SET shelfname=?,owner=?,category=?
+ WHERE shelfnumber=?
+ );
+ my $sth = $dbh->prepare($query);
+ $sth->execute( $shelfname, $owner, $category, $shelfnumber );
+}
+
+=item DelShelf
+
+ ($status) = &DelShelf($shelfnumber);
+
+Deletes virtual bookshelf number C<$shelfnumber>. The bookshelf must
+be empty.
+
+Returns a two-element array, where C<$status> is 0 if the operation
+was successful, or non-zero otherwise. C<$msg> is "Done" in case of
+success, or an error message giving the reason for failure.
+
+=cut
+
+
+=item ShelfPossibleAction
+
+ShelfPossibleAction($loggedinuser, $shelfnumber, $action);
+
+C<$loggedinuser,$shelfnumber,$action>
+
+$action can be "view" or "manage".
+
+Returns 1 if the user can do the $action in the $shelfnumber shelf.
+Returns 0 otherwise.
+
+=cut
+
+sub ShelfPossibleAction {
+ my ( $user, $shelfnumber, $action ) = @_;
+ my $query = qq(
+ SELECT owner,category
+ FROM bookshelf
+ WHERE shelfnumber=?
+ );
+ my $sth = $dbh->prepare($query);
+ $sth->execute($shelfnumber);
+ my ( $owner, $category ) = $sth->fetchrow;
+ return 1 if (($category >= 3 or $owner eq $user) && $action eq 'manage' );
+ return 1 if (($category >= 2 or $owner eq $user) && $action eq 'view' );
+ return 0;
+}
+
+=item DelFromShelf
+
+ &DelFromShelf( $itemnumber, $shelfnumber);
+
+Removes item number C<$itemnumber> from virtual bookshelf number
+C<$shelfnumber>. If the item wasn't on that bookshelf to begin with,
+nothing happens.
+
+=cut
+
+#'
+sub DelFromShelf {
+ my ( $itemnumber, $shelfnumber ) = @_;
+ my $query = qq(
+ DELETE FROM shelfcontents
+ WHERE shelfnumber=? AND itemnumber=?
+ );
+ my $sth = $dbh->prepare($query);
+ $sth->execute( $shelfnumber, $itemnumber );
+}
+
+=head2 DelShelf
+
+ $Number = DelShelf($shelfnumber);
+
+ this function delete the shelf number, and all of it's content
+
+=cut
+
+#'
+sub DelShelf {
+ my ( $shelfnumber ) = @_;
+ my $sth = $dbh->prepare("DELETE FROM bookshelf WHERE shelfnumber=?");
+ $sth->execute($shelfnumber);
+ return 0;
+}
+
+END { } # module clean-up code here (global destructor)
+
+1;
+
+__END__
+
+=back
+
+=head1 AUTHOR
+
+Koha Developement team <info@koha.org>
+
+=head1 SEE ALSO
+
+C4::Circulation::Circ2(3)
+
+=cut
+
+#
+# $Log$
+# Revision 1.21 2007/04/04 16:46:22 tipaul
+# HUGE COMMIT : code cleaning circulation.
+#
+# some stuff to do, i'll write a mail on koha-devel NOW !
+#
+# Revision 1.20 2007/03/09 14:31:47 tipaul
+# rel_3_0 moved to HEAD
+#
+# Revision 1.15.8.10 2007/01/25 13:18:15 tipaul
+# checking that a bookshelf with the same name AND OWNER does not exist before creating it
+#
+# Revision 1.15.8.9 2006/12/15 17:37:52 toins
+# removing a function used only once.
+#
+# Revision 1.15.8.8 2006/12/14 17:22:55 toins
+# bookshelves work perfectly with mod_perl and are cleaned.
+#
+# Revision 1.15.8.7 2006/12/13 19:46:41 hdl
+# Some bug fixing.
+#
+# Revision 1.15.8.6 2006/12/11 17:10:06 toins
+# fixing some bugs on bookshelves.
+#
+# Revision 1.15.8.5 2006/12/07 16:45:43 toins
+# removing warn compilation. (perl -wc)
+#
+# Revision 1.15.8.4 2006/11/23 09:05:01 tipaul
+# enable removal of a bookshelf even if there are items inside
+#
+# Revision 1.15.8.3 2006/10/30 09:50:20 tipaul
+# removing getiteminformations (using direct SQL, as we are in a .pm, so it's "legal")
+#
+# Revision 1.15.8.2 2006/08/31 16:03:52 toins
+# Add Pod to DelShelf
+#
+# Revision 1.15.8.1 2006/08/30 15:59:14 toins
+# Code cleaned according to coding guide lines.
+#
+# Revision 1.15 2004/12/16 11:30:58 tipaul
+# adding bookshelf features :
+# * create bookshelf on the fly
+# * modify a bookshelf name & status
+#
+# Revision 1.14 2004/12/15 17:28:23 tipaul
+# adding bookshelf features :
+# * create bookshelf on the fly
+# * modify a bookshelf (this being not finished, will commit the rest soon)
+++ /dev/null
-#!/usr/bin/perl
-
-#script to provide bookshelf management
-#
-#
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
-
-# $Id$
-
-=head1 NAME
-
- addbookbybiblionumber.pl
-
-=head1 DESCRIPTION
-
- This script allow to add a book in a virtual shelf from a biblionumber.
-
-=head1 CGI PARAMETERS
-
-=over 4
-
-=item biblionumber
-
- The biblionumber
-
-=item shelfnumber
-
- the shelfnumber where to add the book.
-
-=item newbookshelf
-
- if this parameter exists, then it must be equals to the name of the shelf
- to add.
-
-=item category
-
- if this script has to add a shelf, it add one with this category.
-
-=back
-
-=cut
-
-use strict;
-use C4::Biblio;
-use CGI;
-use C4::Output;
-use C4::BookShelves;
-use C4::Circulation;
-use C4::Auth;
-
-
-#use it only to debug !
-use CGI::Carp qw/fatalsToBrowser/;
-use warnings;
-
-my $query = new CGI;
-my $biblionumber = $query->param('biblionumber');
-my $shelfnumber = $query->param('shelfnumber');
-my $newbookshelf = $query->param('newbookshelf');
-my $category = $query->param('category');
-
-my ($template, $loggedinuser, $cookie)
-= get_template_and_user({template_name => "bookshelves/addbookbybiblionumber.tmpl",
- query => $query,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => {catalogue => 1},
- });
-
-$shelfnumber = AddShelf($newbookshelf,$loggedinuser,$category) if $newbookshelf;
-
-if ($shelfnumber || ($shelfnumber == -1)) { # the shelf already exist.
- &AddToShelfFromBiblio($biblionumber, $shelfnumber);
- print "Content-Type: text/html\n\n<html><body onload=\"window.close()\"></body></html>";
- exit;
-} else { # this shelf doesn't already exist.
- my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
-
- my ($shelflist) = GetShelves($loggedinuser,3);
- my @shelvesloop;
- my %shelvesloop;
- foreach my $element (sort keys %$shelflist) {
- push (@shelvesloop, $element);
- $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
- }
-
- my $CGIbookshelves=CGI::scrolling_list(
- -name => 'shelfnumber',
- -values => \@shelvesloop,
- -labels => \%shelvesloop,
- -size => 1,
- -tabindex=>'',
- -multiple => 0 );
-
- $template->param(
- biblionumber => $biblionumber,
- title => $biblios[0]->{'title'},
- author => $biblios[0]->{'author'},
- CGIbookshelves => $CGIbookshelves,
- intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
- intranetstylesheet => C4::Context->preference("intranetstylesheet"),
- IntranetNav => C4::Context->preference("IntranetNav"),
- );
-
- output_html_with_http_headers $query, $cookie, $template->output;
-}
-
-# $Log$
-# Revision 1.8 2007/04/24 13:54:29 hdl
-# functions that were in C4::Interface::CGI::Output are now in C4::Output.
-# So this implies quite a change for files.
-# Sorry about conflicts which will be caused.
-# directory Interface::CGI should now be dropped.
-# I noticed that many scripts (reports ones, but also some circ/stats.pl or opac-topissues) still use Date::Manip.
-#
-# Revision 1.7 2007/04/04 16:46:22 tipaul
-# HUGE COMMIT : code cleaning circulation.
-#
-# some stuff to do, i'll write a mail on koha-devel NOW !
-#
-# Revision 1.6 2007/03/09 14:32:26 tipaul
-# rel_3_0 moved to HEAD
-#
-# Revision 1.4.2.6 2006/12/18 16:35:17 toins
-# removing use HTML::Template from *.pl.
-#
-# Revision 1.4.2.5 2006/12/05 11:35:29 toins
-# Biblio.pm cleaned.
-# additionalauthors, bibliosubject, bibliosubtitle tables are now unused.
-# Some functions renamed according to the coding guidelines.
-#
-# Revision 1.4.2.4 2006/11/30 18:23:51 toins
-# theses scripts don't need to use C4::Search.
-#
-# Revision 1.4.2.3 2006/10/30 09:48:19 tipaul
-# samll bugfix to create a bookshelf correctly
-#
-# Revision 1.4.2.2 2006/08/30 16:13:54 toins
-# correct an error in the "if condition".
-#
-# Revision 1.4.2.1 2006/08/30 15:59:14 toins
-# Code cleaned according to coding guide lines.
-#
-# Revision 1.4 2006/07/04 14:36:51 toins
-# Head & rel_2_2 merged
-#
-# Revision 1.3.2.4 2006/06/20 16:21:42 oleonard
-# Adding "tabindex=''" to CGI:scrolling_lists to prevent incorrect tabbing. See Bug 1098
-#
-# Revision 1.3.2.3 2006/02/05 21:59:21 kados
-# Adds script support for IntranetNav ... see mail to koha-devel for
-# details
-#
-# Revision 1.3.2.2 2006/02/05 21:45:25 kados
-# Adds support for intranetstylesheet system pref in Koha scripts
-#
-
-# Local Variables:
-# tab-width: 4
-# End:
+++ /dev/null
-#!/usr/bin/perl
-
-#
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
-
-=head1 NAME
-
- shelves.pl
-
-=head1 DESCRIPTION
-
- this script is used to script to provide bookshelf management
-
-=head1 CGI PARAMETERS
-
-=over 4
-
-=item C<modifyshelfcontents>
-
- if this script has to modify the shelve content.
-
-=item C<shelfnumber>
-
- to know on which shelve this script has to work.
-
-=item C<addbarcode>
-
-=item C<op>
-
- op can be equals to:
- * modifsave to save change on the shelves
- * modif to change the template to allow to modify the shelves.
-
-=item C<viewshelf>
-
- to load the template with 'viewshelves param' which allow to read the shelves information.
-
-=item C<shelves>
-
- if equals to 1. then call the function shelves which add
- or delete a shelf.
-
-=item C<addshelf>
-
- if the param shelves = 1 then addshelf must be equals to the name of the shelf to add.
-
-=back
-
-=cut
-
-use strict;
-use CGI;
-use C4::BookShelves;
-use C4::Biblio;
-use C4::Auth;
-use C4::Output;
-
-my $query = new CGI;
-
-my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
- {
- template_name => "bookshelves/shelves.tmpl",
- query => $query,
- type => "intranet",
- authnotrequired => 0,
- flagsrequired => { catalogue => 1 },
- }
-);
-
-if ( $query->param('modifyshelfcontents') ) {
- my $shelfnumber = $query->param('viewshelf');
- my $barcode = $query->param('addbarcode');
- my ($item) = GetItem( 0, $barcode );
- if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ) ) {
- AddToShelf( $item->{'itemnumber'}, $shelfnumber );
- foreach ( $query->param ) {
- if (/REM-(\d*)/) {
- my $itemnumber = $1;
- DelFromShelf( $itemnumber, $shelfnumber );
- }
- }
- }
-}
-
-# getting the Shelves list
-my $shelflist = GetShelves( $loggedinuser, 2 );
-$template->param( { loggedinuser => $loggedinuser } );
-my $op = $query->param('op');
-
-SWITCH: {
- if ( $op && ( $op eq 'modifsave' ) ) {
- ModShelf(
- $query->param('shelfnumber'), $query->param('shelfname'),
- $loggedinuser, $query->param('category')
- );
- last SWITCH;
- }
- if ( $op && ( $op eq 'modif' ) ) {
- my ( $shelfnumber, $shelfname, $owner, $category ) =
- GetShelf( $query->param('shelf') );
- $template->param(
- edit => 1,
- shelfnumber => $shelfnumber,
- shelfname => $shelfname,
- "category$category" => 1
- );
-
- # editshelf($query->param('shelf'));
- last SWITCH;
- }
- if ( $query->param('viewshelf') ) {
- #check that the user can view the shelf
- my $shelfnumber = $query->param('viewshelf');
- if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
- my $items = GetShelfContents($shelfnumber);
- $template->param(
- shelfname => $shelflist->{$shelfnumber}->{'shelfname'},
- shelfnumber => $shelfnumber,
- viewshelf => $query->param('viewshelf'),
- manageshelf => &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ),
- itemsloop => $items,
- );
- }
- last SWITCH;
- }
- if ( $query->param('shelves') ) {
- if ( my $newshelf = $query->param('addshelf') ) {
- my $shelfnumber = AddShelf(
- $newshelf,
- $query->param('owner'),
- $query->param('category')
- );
-
- if ( $shelfnumber == -1 ) { #shelf already exists.
- $template->param(
- {
- shelfnumber => $shelfnumber,
- already => 1
- }
- );
- }
- }
- my @paramsloop;
- foreach ( $query->param() ) {
- my %line;
- if (/DEL-(\d+)/) {
- my $delshelf = $1;
- my ( $status, $count ) = DelShelf($delshelf);
- if ($status) {
- $line{'status'} = $status;
- $line{'count'} = $count;
- }
- }
-
- #if the shelf is not deleted, %line points on null
- push( @paramsloop, \%line );
- }
- $template->param( paramsloop => \@paramsloop );
- my ($shelflist) = GetShelves( $loggedinuser, 2 );
- my $color = '';
- my @shelvesloop;
- foreach my $element ( sort keys %$shelflist ) {
- my %line;
- ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
- $line{'toggle'} = $color;
- $line{'shelf'} = $element;
- $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
- $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
- push( @shelvesloop, \%line );
- }
- $template->param(
- shelvesloop => \@shelvesloop,
- shelves => 1,
- );
- last SWITCH;
- }
-}
-
-($shelflist) =
- GetShelves( $loggedinuser, 2 )
- ; # rebuild shelflist in case a shelf has been added
-
-my $color = '';
-my @shelvesloop;
-my $numberCanManage = 0;
-
-foreach my $element ( sort keys %$shelflist ) {
- my %line;
- ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
- $line{'toggle'} = $color;
- $line{'shelf'} = $element;
- $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
- $line{ "category" . $shelflist->{$element}->{'category'} } = 1;
- $line{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser;
- $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
- $line{'canmanage'} = ShelfPossibleAction( $loggedinuser, $element, 'manage' );
- $line{'firstname'} = $shelflist->{$element}->{'firstname'}
- unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
- $line{'surname'} = $shelflist->{$element}->{'surname'}
- unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
-
- $numberCanManage++ if $line{'canmanage'};
-
- push( @shelvesloop, \%line );
-}
-
-$template->param(
- shelvesloop => \@shelvesloop,
- numberCanManage => $numberCanManage,
-);
-
-output_html_with_http_headers $query, $cookie, $template->output;
-
-sub shelves {
- my $innertemplate = shift;
- if ( my $newshelf = $query->param('addshelf') ) {
- my $shelfnumber = AddShelf(
- $newshelf,
- $query->param('owner'),
- $query->param('category')
- );
-
- if ( $shelfnumber == -1 ) { #shelf already exists.
- $template->param(
- {
- shelfnumber => $shelfnumber,
- already => 1
- }
- );
- }
- }
- my @paramsloop;
- foreach ( $query->param() ) {
- my %line;
- if (/DEL-(\d+)/) {
- my $delshelf = $1;
- my ( $status, $count ) = DelShelf($delshelf);
- if ($status) {
- $line{'status'} = $status;
- $line{'count'} = $count;
- }
- }
-
- #if the shelf is not deleted, %line points on null
- push( @paramsloop, \%line );
- }
- $innertemplate->param( paramsloop => \@paramsloop );
- my ($shelflist) = GetShelves( $loggedinuser, 2 );
- my $color = '';
- my @shelvesloop;
- foreach my $element ( sort keys %$shelflist ) {
- my %line;
- ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
- $line{'toggle'} = $color;
- $line{'shelf'} = $element;
- $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
- $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
- push( @shelvesloop, \%line );
- }
- $innertemplate->param(
- shelvesloop => \@shelvesloop,
- shelves => 1,
- );
-}
-
-#
-# $Log$
-# Revision 1.13 2007/04/24 13:54:29 hdl
-# functions that were in C4::Interface::CGI::Output are now in C4::Output.
-# So this implies quite a change for files.
-# Sorry about conflicts which will be caused.
-# directory Interface::CGI should now be dropped.
-# I noticed that many scripts (reports ones, but also some circ/stats.pl or opac-topissues) still use Date::Manip.
-#
-# Revision 1.12 2007/04/04 16:46:22 tipaul
-# HUGE COMMIT : code cleaning circulation.
-#
-# some stuff to do, i'll write a mail on koha-devel NOW !
-#
-# Revision 1.11 2007/03/09 14:32:26 tipaul
-# rel_3_0 moved to HEAD
-#
-# Revision 1.9.2.9 2007/02/05 15:54:30 toins
-# don't display "remove selected shelves" if the user logged has no shelf.
-#
-# Revision 1.9.2.8 2006/12/15 17:36:57 toins
-# - some change on the html param.
-# - Writing directly the code of a sub called only once.
-# - adding syspref: BiblioDefaultView.
-#
-# Revision 1.9.2.7 2006/12/14 17:22:55 toins
-# bookshelves work perfectly with mod_perl and are cleaned.
-#
-# Revision 1.9.2.6 2006/12/13 10:06:05 toins
-# fix a mod_perl specific bug.
-#
-# Revision 1.9.2.5 2006/12/11 17:10:06 toins
-# fixing some bugs on bookshelves.
-#
-# Revision 1.9.2.4 2006/11/30 18:23:51 toins
-# theses scripts don't need to use C4::Search.
-#
-# Revision 1.9.2.3 2006/10/30 09:50:45 tipaul
-# better perl writting
-#
-# Revision 1.9.2.2 2006/10/17 07:59:35 toins
-# ccode added.
-#
+++ /dev/null
-<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
-<title>Koha › Add to Virtual Shelf</title>
-<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
-
-<h1>Add
- <i><!-- TMPL_VAR NAME="title" --></i>
- <!-- TMPL_IF NAME="author" -->
- by <!-- TMPL_VAR NAME="author" -->
- <!-- /TMPL_IF --> to a virtual shelf
-</h1>
-
-<form name="f1" method="post" action="/cgi-bin/koha/bookshelves/addbookbybiblionumber.pl">
- <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->">
-
- <b>Select an existing shelf</b>
- <p>
- <label>Add to virtual shelf</label><!-- TMPL_VAR NAME="CGIbookshelves" -->
- </p>
- <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
- <input type="submit" value="Add to virtual shelf" class="submit" />
-</form>
-<p>...or...</p>
-<form name="f2" method="post" action="/cgi-bin/koha/bookshelves/addbookbybiblionumber.pl">
- <b>Add to a new shelf:</b>
- <p>
- <label for="newbookshelf">
- Shelf name:
- </label>
- <input type="text" name="newbookshelf" id="newbookshelf" size="40" />
- </p>
- <p>
- <label for="category">Category:</label>
- <select name="category" id="category">
- <option value="1">Private</option>
- <option value="2">Public</option>
- </select>
- </p>
- <input type="submit" value="Add to virtual shelf" class="submit" />
-</form>
-
-</body>
-</html>
+++ /dev/null
-<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
-<title>Koha › Add to Virtual Shelf</title>
-<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
-
-<!-- TMPL_INCLUDE NAME="menus.inc" -->
-<!-- TMPL_INCLUDE NAME="menu-bookshelves.inc" -->
-
-<!-- TMPL_IF Name="viewshelf" -->
-
-<div id="action">
- <a class="button" href="/cgi-bin/koha/bookshelves/shelves.pl">Back to virtual Shelves</a>
- <!-- TMPL_IF name="manageshelf" -->
- <a class="button" href="/cgi-bin/koha/bookshelves/shelves.pl?op=modif&shelf=<!-- TMPL_VAR Name="shelfnumber" -->">
- Modify this shelf</a>
- <!-- /TMPL_IF -->
-</div>
-
-<h3>Contents of <!-- TMPL_VAR Name="shelfname" --></h3>
-
-<form class="inline" action="/cgi-bin/koha/bookshelves/shelves.pl" method="post" name="mainform">
- <!-- TMPL_IF NAME="itemsloop" -->
- <table>
- <input type="hidden" name="viewshelf" value="<!-- TMPL_VAR Name="shelfnumber" -->" />
- <input type="hidden" name="modifyshelfcontents" value="1" />
- <tr>
- <th>
- <a href="javascript:CheckAll();">
- <small>(Un)Check All</small>
- </a>
- </th>
- <th> </th>
- <th>Title</th>
- <th>Author</th>
- <th>Call No.</th>
- </tr>
- <!-- TMPL_LOOP Name="itemsloop" -->
- <tr<!-- TMPL_IF name="color" --> class="highlight"<!-- /TMPL_IF -->>
- <td>
- <input type="checkbox" name="REM-<!-- TMPL_VAR Name="itemnumber" -->" />
- </td>
- <td>
- <img src="<!-- TMPL_VAR NAME="themelang" -->/images/<!-- TMPL_VAR NAME="itemtype" -->.gif" alt="<!-- TMPL_VAR NAME="itemtype" -->" title="<!-- TMPL_VAR NAME="itemtype" -->" />
- </td>
- <td>
- <!-- TMPL_IF name="BiblioDefaultViewmarc" -->
- <a class="title" href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
- <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" -->
- </a>
- <!-- TMPL_ELSE -->
- <!-- TMPL_IF name="BiblioDefaultViewisbd" -->
- <a class="title" href="/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
- <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" -->
- </a>
- <!-- TMPL_ELSE -->
- <a class="title" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
- <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" -->
- </a>
- <!-- /TMPL_IF -->
- <!-- /TMPL_IF -->
- </td>
- <td><!-- TMPL_VAR Name="author" --></td>
- <td><!-- TMPL_VAR NAME="classification" --></td>
- </tr>
- <!-- /TMPL_LOOP -->
- </table>
- <!-- TMPL_ELSE -->
- <br />
- <b>This shelf is empty.</b>
- <!-- TMPL_UNLESS NAME="itemsloop" -->
- <input type="hidden" name="DEL-<!-- TMPL_VAR NAME="shelfnumber" -->" />
- <input type="hidden" name="shelves" value="1" />
- <input type="submit" class="icon delete"
- value="Delete this shelf"
- onclick="return confirmDelete('Are you sure you want to delete this shelf?')" />
- <!-- /TMPL_UNLESS -->
- <!-- /TMPL_IF -->
- <!-- TMPL_IF name="manageshelf" -->
- <!-- TMPL_IF NAME="itemsloop" -->
- <b>With selected items :</b>
- <input type="submit"
- value="Remove"
- class="icon delete"
- onclick="return confirmDelete('Are you sure you want to remove these items from the shelf?')"
- style="display:inline;"
- />
- <!-- /TMPL_IF -->
- <!-- /TMPL_IF -->
-</form>
- <!-- TMPL_IF name="manageshelf" -->
-
-<br />
-<form action="/cgi-bin/koha/bookshelves/shelves.pl" method="post">
- <table>
- <tr><th colspan="2">Add an item to this shelf by barcode</th></tr>
- <tr>
- <td>
- <label for="addbarcode">Barcode:</label>
- </td>
- <td>
- <input name="addbarcode" type="text" id="addbarcode" size="14" maxlength="14" />
- <input type="hidden" name="viewshelf" value="<!-- TMPL_VAR Name="shelfnumber" -->" />
- <input type="hidden" name="modifyshelfcontents" value="1" />
- <input type="submit" value="Save" />
- </td>
- </tr>
- </table>
-</form>
-<!-- /TMPL_IF -->
-<!-- TMPL_ELSE -->
- <!-- TMPL_IF Name="shelves" -->
- <!-- TMPL_IF Name="status1" -->
- <p class="error"><!-- TMPL_VAR Name="string1" --></p>
- <!-- /TMPL_IF -->
- <!-- TMPL_LOOP Name="paramsloop" -->
- <!-- TMPL_IF Name="status" -->
- <p class="error"><!-- TMPL_VAR Name="string" --></p>
- <!-- /TMPL_IF -->
- <!-- /TMPL_LOOP -->
- <form method="post" action="/cgi-bin/koha/bookshelves/shelves.pl">
- <input type="hidden" name="shelves" value="1">
- <h3>Create a new virtual shelf</h3>
- <table>
- <tr><th scope="row"><label for="addshelf">Shelf name:</label> </th><td> <input id="addshelf" type="text" name="addshelf" size="25"></td></tr>
- <tr><th scope="row"><label for="owner">Owner:</label> </th><td><input type="hidden" name="owner" id="owner" value="<!-- TMPL_VAR name="loggedinuser" -->"><!-- TMPL_VAR name="loggedinusername" --></td></tr>
- <tr><th scope="row"><label for="category">Category:</label> </th><td><select name="category" id="category">
- <option value="1">Private</option>
- <option value="2">Public</option>
- </select></td></tr></table>
- <ul>
- <li>A <b>private</b> virtual shelf is managed by you and can be seen only by you.</li>
- <li> A <b>public</b> virtual shelf can be seen by everybody, but managed only by you.</li>
- </ul>
- <p><input type="submit" value="Add a new shelf"></p>
- </form>
-
- <!-- TMPL_IF NAME="numberCanManage" -->
- <!-- TMPL_IF NAME="shelvesloop" -->
- <form method="post" action="/cgi-bin/koha/bookshelves/shelves.pl" name="mainform">
- <input type="hidden" name="shelves" value="1" />
- <h3>Delete virtual shelves</h3>
- <table>
- <tr><th> </th><th>Shelf name</th><th>Contents</th></tr>
- <!-- TMPL_LOOP Name="shelvesloop" -->
- <!-- TMPL_IF name="canmanage" -->
- <tr>
- <td>
- <input type="checkbox" name="DEL-<!-- TMPL_VAR Name="shelf" -->" />
- </td>
- <td>
- <a href="/cgi-bin/koha/bookshelves/shelves.pl?viewshelf=<!-- TMPL_VAR Name="shelf" -->"><!-- TMPL_VAR Name="shelfname" --></a>
- </td>
- <td>
- <!-- TMPL_VAR Name="shelfbookcount" --> item(s)
- </td>
- </tr>
- <!-- /TMPL_IF -->
- <!-- /TMPL_LOOP -->
- </table>
- <input type="submit" value="Delete shelves" /></form>
- <!-- /TMPL_IF -->
- <!-- /TMPL_IF -->
- <br />
- <p><form class="inline" action="/cgi-bin/koha/bookshelves/shelves.pl" method="get"><input type="submit" value="Back to virtual shelves" /></form></p>
-
- <!-- TMPL_ELSE -->
- <!-- TMPL_IF name="edit" -->
- <form method="post">
- <input type="hidden" name="op" value="modifsave">
- <input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR name="shelfnumber" -->">
-<h3>Modify virtual shelf <!-- TMPL_VAR name="shelfname"--></h3>
- <table>
- <tr><td><label for="shelfname">Shelf name: </label></td><td><input type="text" id="shelfname" name="shelfname" size="25" value="<!-- TMPL_VAR name="shelfname"-->" /></td></tr>
- <tr><td><label for="owner">Owner: </label></td><td><input type="hidden" id="owner" name="owner" value="<!-- TMPL_VAR NAME="loggedinuser" -->"><!-- TMPL_VAR NAME="loggedinusername" --></td></tr>
- <tr><td><label for="category">Category: </label></td><td><select id="category" name="category">
- <!-- TMPL_IF name="category1" -->
- <option value="1" selected>Private</option>
- <!-- TMPL_ELSE -->
- <option value="1">Private</option>
- <!-- /TMPL_IF -->
- <!-- TMPL_IF name="category2" -->
- <option value="2" selected>Public</option>
- <!-- TMPL_ELSE -->
- <option value="2">Public</option>
- <!-- /TMPL_IF -->
- </select></td></tr>
- </table>
- <ul><li>A <strong>private</strong> virtual shelf is managed by you and can be seen <strong>only</strong> by you.</li>
- <li> A <strong>public</strong> virtual shelf can be seen by <strong>everybody</strong>, but managed only by you.</li>
- </ul>
- <p><input type="submit" value="Save changes"></p>
-
- </form>
-<!-- /TMPL_IF -->
-<h3>Virtual shelves</h3>
-
-<table>
-<tr><th>Shelf name</th><th>Category</th><th>Content size</th><th> </th></tr>
-<!-- TMPL_LOOP Name="shelvesloop" -->
-<tr<!-- TMPL_IF name="color" --> class="highlight"<!-- /TMPL_IF -->><td><a href="/cgi-bin/koha/bookshelves/shelves.pl?viewshelf=<!-- TMPL_VAR Name="shelf" -->"><!-- TMPL_VAR Name="shelfname" --></a></td><td><!-- TMPL_IF NAME="category1" -->Private<!-- /TMPL_IF --><!-- TMPL_IF NAME="category2" -->Public<!-- /TMPL_IF --><!-- TMPL_IF NAME="category3" -->Free<!-- /TMPL_IF --></td><td><!-- TMPL_VAR Name="shelfbookcount" --> item(s)</td><td><!-- TMPL_IF name="mine" --><a href="/cgi-bin/koha/bookshelves/shelves.pl?op=modif&shelf=<!-- TMPL_VAR NAME="shelf" -->">Modify</a><!-- TMPL_ELSE --> <!-- /TMPL_IF --></td></tr>
- <!-- /TMPL_LOOP -->
- </table>
- <p><form action="/cgi-bin/koha/bookshelves/shelves.pl" method="get"><input type="hidden" value="1" name="shelves" /><input type="submit" value="Add or remove virtual shelves" /></form></p>
- <!-- /TMPL_IF -->
-<!-- /TMPL_IF -->
-
-<br clear="both" />
-
-<script type="text/javascript">
- function confirmDelete(s){
- if (window.confirm(s))
- return true;
- return false;
- }
- /**
- * this function checks all checkbox
- * or uncheck all if there are already checked.
- */
- function CheckAll(){
- var checkboxes = document.getElementsByTagName('input');
- var nbCheckbox = checkboxes.length;
- var check = areAllChecked();
- check = !check;
- for(var i=0;i<nbCheckbox;i++){
- if(checkboxes[i].getAttribute('type') == "checkbox" ){
- checkboxes[i].checked = check;
- }
- }
- }
- /**
- * this function return true if all checkbox are checked
- */
- function areAllChecked(){
- var checkboxes = document.getElementsByTagName('input');
- var nbCheckbox = checkboxes.length;
- for(var i=0;i<nbCheckbox;i++){
- if(checkboxes[i].getAttribute('type') == "checkbox" ){
- if(checkboxes[i].checked == 0){
- return false;
- }
- }
- }
- return true;
- }
-
-</script>
-
-<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
+++ /dev/null
-<div id="submenu">
- <a href="/cgi-bin/koha/bookshelves/shelves.pl">Shelves</a>
-</div>
-
-<div id="main">
\ No newline at end of file
--- /dev/null
+<div id="submenu">
+ <a href="/cgi-bin/koha/bookshelves/shelves.pl">Shelves</a>
+</div>
+
+<div id="main">
\ No newline at end of file
--- /dev/null
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha › Add to Virtual Shelf</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+
+<h1>Add
+ <i><!-- TMPL_VAR NAME="title" --></i>
+ <!-- TMPL_IF NAME="author" -->
+ by <!-- TMPL_VAR NAME="author" -->
+ <!-- /TMPL_IF --> to a virtual shelf
+</h1>
+
+<form name="f1" method="post" action="/cgi-bin/koha/bookshelves/addbookbybiblionumber.pl">
+ <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->">
+
+ <b>Select an existing shelf</b>
+ <p>
+ <label>Add to virtual shelf</label><!-- TMPL_VAR NAME="CGIbookshelves" -->
+ </p>
+ <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
+ <input type="submit" value="Add to virtual shelf" class="submit" />
+</form>
+<p>...or...</p>
+<form name="f2" method="post" action="/cgi-bin/koha/bookshelves/addbookbybiblionumber.pl">
+ <b>Add to a new shelf:</b>
+ <p>
+ <label for="newbookshelf">
+ Shelf name:
+ </label>
+ <input type="text" name="newbookshelf" id="newbookshelf" size="40" />
+ </p>
+ <p>
+ <label for="category">Category:</label>
+ <select name="category" id="category">
+ <option value="1">Private</option>
+ <option value="2">Public</option>
+ </select>
+ </p>
+ <input type="submit" value="Add to virtual shelf" class="submit" />
+</form>
+
+</body>
+</html>
--- /dev/null
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<title>Koha › Add to Virtual Shelf</title>
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+
+<!-- TMPL_INCLUDE NAME="menus.inc" -->
+<!-- TMPL_INCLUDE NAME="menu-bookshelves.inc" -->
+
+<!-- TMPL_IF Name="viewshelf" -->
+
+<div id="action">
+ <a class="button" href="/cgi-bin/koha/bookshelves/shelves.pl">Back to virtual Shelves</a>
+ <!-- TMPL_IF name="manageshelf" -->
+ <a class="button" href="/cgi-bin/koha/bookshelves/shelves.pl?op=modif&shelf=<!-- TMPL_VAR Name="shelfnumber" -->">
+ Modify this shelf</a>
+ <!-- /TMPL_IF -->
+</div>
+
+<h3>Contents of <!-- TMPL_VAR Name="shelfname" --></h3>
+
+<form class="inline" action="/cgi-bin/koha/bookshelves/shelves.pl" method="post" name="mainform">
+ <!-- TMPL_IF NAME="itemsloop" -->
+ <table>
+ <input type="hidden" name="viewshelf" value="<!-- TMPL_VAR Name="shelfnumber" -->" />
+ <input type="hidden" name="modifyshelfcontents" value="1" />
+ <tr>
+ <th>
+ <a href="javascript:CheckAll();">
+ <small>(Un)Check All</small>
+ </a>
+ </th>
+ <th> </th>
+ <th>Title</th>
+ <th>Author</th>
+ <th>Call No.</th>
+ </tr>
+ <!-- TMPL_LOOP Name="itemsloop" -->
+ <tr<!-- TMPL_IF name="color" --> class="highlight"<!-- /TMPL_IF -->>
+ <td>
+ <input type="checkbox" name="REM-<!-- TMPL_VAR Name="itemnumber" -->" />
+ </td>
+ <td>
+ <img src="<!-- TMPL_VAR NAME="themelang" -->/images/<!-- TMPL_VAR NAME="itemtype" -->.gif" alt="<!-- TMPL_VAR NAME="itemtype" -->" title="<!-- TMPL_VAR NAME="itemtype" -->" />
+ </td>
+ <td>
+ <!-- TMPL_IF name="BiblioDefaultViewmarc" -->
+ <a class="title" href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+ <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" -->
+ </a>
+ <!-- TMPL_ELSE -->
+ <!-- TMPL_IF name="BiblioDefaultViewisbd" -->
+ <a class="title" href="/cgi-bin/koha/catalogue/ISBDdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+ <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" -->
+ </a>
+ <!-- TMPL_ELSE -->
+ <a class="title" href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" ESCAPE="URL" -->">
+ <!-- TMPL_VAR NAME="title" --> <!-- TMPL_VAR NAME="subtitle" -->
+ </a>
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_IF -->
+ </td>
+ <td><!-- TMPL_VAR Name="author" --></td>
+ <td><!-- TMPL_VAR NAME="classification" --></td>
+ </tr>
+ <!-- /TMPL_LOOP -->
+ </table>
+ <!-- TMPL_ELSE -->
+ <br />
+ <b>This shelf is empty.</b>
+ <!-- TMPL_UNLESS NAME="itemsloop" -->
+ <input type="hidden" name="DEL-<!-- TMPL_VAR NAME="shelfnumber" -->" />
+ <input type="hidden" name="shelves" value="1" />
+ <input type="submit" class="icon delete"
+ value="Delete this shelf"
+ onclick="return confirmDelete('Are you sure you want to delete this shelf?')" />
+ <!-- /TMPL_UNLESS -->
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="manageshelf" -->
+ <!-- TMPL_IF NAME="itemsloop" -->
+ <b>With selected items :</b>
+ <input type="submit"
+ value="Remove"
+ class="icon delete"
+ onclick="return confirmDelete('Are you sure you want to remove these items from the shelf?')"
+ style="display:inline;"
+ />
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_IF -->
+</form>
+ <!-- TMPL_IF name="manageshelf" -->
+
+<br />
+<form action="/cgi-bin/koha/bookshelves/shelves.pl" method="post">
+ <table>
+ <tr><th colspan="2">Add an item to this shelf by barcode</th></tr>
+ <tr>
+ <td>
+ <label for="addbarcode">Barcode:</label>
+ </td>
+ <td>
+ <input name="addbarcode" type="text" id="addbarcode" size="14" maxlength="14" />
+ <input type="hidden" name="viewshelf" value="<!-- TMPL_VAR Name="shelfnumber" -->" />
+ <input type="hidden" name="modifyshelfcontents" value="1" />
+ <input type="submit" value="Save" />
+ </td>
+ </tr>
+ </table>
+</form>
+<!-- /TMPL_IF -->
+<!-- TMPL_ELSE -->
+ <!-- TMPL_IF Name="shelves" -->
+ <!-- TMPL_IF Name="status1" -->
+ <p class="error"><!-- TMPL_VAR Name="string1" --></p>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_LOOP Name="paramsloop" -->
+ <!-- TMPL_IF Name="status" -->
+ <p class="error"><!-- TMPL_VAR Name="string" --></p>
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP -->
+ <form method="post" action="/cgi-bin/koha/bookshelves/shelves.pl">
+ <input type="hidden" name="shelves" value="1">
+ <h3>Create a new virtual shelf</h3>
+ <table>
+ <tr><th scope="row"><label for="addshelf">Shelf name:</label> </th><td> <input id="addshelf" type="text" name="addshelf" size="25"></td></tr>
+ <tr><th scope="row"><label for="owner">Owner:</label> </th><td><input type="hidden" name="owner" id="owner" value="<!-- TMPL_VAR name="loggedinuser" -->"><!-- TMPL_VAR name="loggedinusername" --></td></tr>
+ <tr><th scope="row"><label for="category">Category:</label> </th><td><select name="category" id="category">
+ <option value="1">Private</option>
+ <option value="2">Public</option>
+ </select></td></tr></table>
+ <ul>
+ <li>A <b>private</b> virtual shelf is managed by you and can be seen only by you.</li>
+ <li> A <b>public</b> virtual shelf can be seen by everybody, but managed only by you.</li>
+ </ul>
+ <p><input type="submit" value="Add a new shelf"></p>
+ </form>
+
+ <!-- TMPL_IF NAME="numberCanManage" -->
+ <!-- TMPL_IF NAME="shelvesloop" -->
+ <form method="post" action="/cgi-bin/koha/bookshelves/shelves.pl" name="mainform">
+ <input type="hidden" name="shelves" value="1" />
+ <h3>Delete virtual shelves</h3>
+ <table>
+ <tr><th> </th><th>Shelf name</th><th>Contents</th></tr>
+ <!-- TMPL_LOOP Name="shelvesloop" -->
+ <!-- TMPL_IF name="canmanage" -->
+ <tr>
+ <td>
+ <input type="checkbox" name="DEL-<!-- TMPL_VAR Name="shelf" -->" />
+ </td>
+ <td>
+ <a href="/cgi-bin/koha/bookshelves/shelves.pl?viewshelf=<!-- TMPL_VAR Name="shelf" -->"><!-- TMPL_VAR Name="shelfname" --></a>
+ </td>
+ <td>
+ <!-- TMPL_VAR Name="shelfbookcount" --> item(s)
+ </td>
+ </tr>
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_LOOP -->
+ </table>
+ <input type="submit" value="Delete shelves" /></form>
+ <!-- /TMPL_IF -->
+ <!-- /TMPL_IF -->
+ <br />
+ <p><form class="inline" action="/cgi-bin/koha/bookshelves/shelves.pl" method="get"><input type="submit" value="Back to virtual shelves" /></form></p>
+
+ <!-- TMPL_ELSE -->
+ <!-- TMPL_IF name="edit" -->
+ <form method="post">
+ <input type="hidden" name="op" value="modifsave">
+ <input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR name="shelfnumber" -->">
+<h3>Modify virtual shelf <!-- TMPL_VAR name="shelfname"--></h3>
+ <table>
+ <tr><td><label for="shelfname">Shelf name: </label></td><td><input type="text" id="shelfname" name="shelfname" size="25" value="<!-- TMPL_VAR name="shelfname"-->" /></td></tr>
+ <tr><td><label for="owner">Owner: </label></td><td><input type="hidden" id="owner" name="owner" value="<!-- TMPL_VAR NAME="loggedinuser" -->"><!-- TMPL_VAR NAME="loggedinusername" --></td></tr>
+ <tr><td><label for="category">Category: </label></td><td><select id="category" name="category">
+ <!-- TMPL_IF name="category1" -->
+ <option value="1" selected>Private</option>
+ <!-- TMPL_ELSE -->
+ <option value="1">Private</option>
+ <!-- /TMPL_IF -->
+ <!-- TMPL_IF name="category2" -->
+ <option value="2" selected>Public</option>
+ <!-- TMPL_ELSE -->
+ <option value="2">Public</option>
+ <!-- /TMPL_IF -->
+ </select></td></tr>
+ </table>
+ <ul><li>A <strong>private</strong> virtual shelf is managed by you and can be seen <strong>only</strong> by you.</li>
+ <li> A <strong>public</strong> virtual shelf can be seen by <strong>everybody</strong>, but managed only by you.</li>
+ </ul>
+ <p><input type="submit" value="Save changes"></p>
+
+ </form>
+<!-- /TMPL_IF -->
+<h3>Virtual shelves</h3>
+
+<table>
+<tr><th>Shelf name</th><th>Category</th><th>Content size</th><th> </th></tr>
+<!-- TMPL_LOOP Name="shelvesloop" -->
+<tr<!-- TMPL_IF name="color" --> class="highlight"<!-- /TMPL_IF -->><td><a href="/cgi-bin/koha/bookshelves/shelves.pl?viewshelf=<!-- TMPL_VAR Name="shelf" -->"><!-- TMPL_VAR Name="shelfname" --></a></td><td><!-- TMPL_IF NAME="category1" -->Private<!-- /TMPL_IF --><!-- TMPL_IF NAME="category2" -->Public<!-- /TMPL_IF --><!-- TMPL_IF NAME="category3" -->Free<!-- /TMPL_IF --></td><td><!-- TMPL_VAR Name="shelfbookcount" --> item(s)</td><td><!-- TMPL_IF name="mine" --><a href="/cgi-bin/koha/bookshelves/shelves.pl?op=modif&shelf=<!-- TMPL_VAR NAME="shelf" -->">Modify</a><!-- TMPL_ELSE --> <!-- /TMPL_IF --></td></tr>
+ <!-- /TMPL_LOOP -->
+ </table>
+ <p><form action="/cgi-bin/koha/bookshelves/shelves.pl" method="get"><input type="hidden" value="1" name="shelves" /><input type="submit" value="Add or remove virtual shelves" /></form></p>
+ <!-- /TMPL_IF -->
+<!-- /TMPL_IF -->
+
+<br clear="both" />
+
+<script type="text/javascript">
+ function confirmDelete(s){
+ if (window.confirm(s))
+ return true;
+ return false;
+ }
+ /**
+ * this function checks all checkbox
+ * or uncheck all if there are already checked.
+ */
+ function CheckAll(){
+ var checkboxes = document.getElementsByTagName('input');
+ var nbCheckbox = checkboxes.length;
+ var check = areAllChecked();
+ check = !check;
+ for(var i=0;i<nbCheckbox;i++){
+ if(checkboxes[i].getAttribute('type') == "checkbox" ){
+ checkboxes[i].checked = check;
+ }
+ }
+ }
+ /**
+ * this function return true if all checkbox are checked
+ */
+ function areAllChecked(){
+ var checkboxes = document.getElementsByTagName('input');
+ var nbCheckbox = checkboxes.length;
+ for(var i=0;i<nbCheckbox;i++){
+ if(checkboxes[i].getAttribute('type') == "checkbox" ){
+ if(checkboxes[i].checked == 0){
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+</script>
+
+<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->
+++ /dev/null
-<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
-<!-- TMPL_VAR NAME="LibraryNameTitle" --> Catalog -- Add to My Book List
-<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
-
-
-<!-- TMPL_IF NAME="multiple"-->
- <h1>Add these <!-- TMPL_VAR NAME="total"--> biblios to a shelf</h1>
- <!-- TMPL_LOOP NAME="biblios"-->
- <b><!-- TMPL_VAR NAME="title"--></b>
- <!-- TMPL_IF NAME="author"-->by <!-- TMPL_VAR NAME="author"--><!-- /TMPL_IF -->
- <br /><br />
- <!-- /TMPL_LOOP -->
-<!-- TMPL_ELSE -->
-<h1>Add
- <i><!-- TMPL_VAR NAME="title" --></i>
- <!-- TMPL_IF NAME="author" -->
- by <!-- TMPL_VAR NAME="author" -->
- <!-- /TMPL_IF --> to a Virtual Shelf
-</h1>
-<!-- /TMPL_IF -->
-
-<!-- TMPL_IF NAME="CGIbookshelves"-->
-<form name="f1" action="/cgi-bin/koha/opac-addbookbybiblionumber.pl" method="post">
- <p><b>Select an Existing Bookshelf</b></p>
- <label>Add to virtual shelf</label> <!-- TMPL_VAR NAME="CGIbookshelves" -->
- <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
- <input type="hidden" name="modifyshelfcontents" value="1" />
- <input type="submit" value="Add to virtual shelf" class="submit" />
-</form>
-<p>...or...</p>
-<!-- /TMPL_IF -->
-
-<form name="f2" method="post" action="/cgi-bin/koha/opac-addbookbybiblionumber.pl">
- <b>Add to a New Bookshelf:</b>
- <p>
- <label for="newbookshelf">
- Shelf Name:
- </label>
- <input type="text" name="newbookshelf" id="newbookshelf" size="40" />
- </p>
- <label for="category">Category:</label>
- <select name="category" id="category">
- <option value="1">Private</option>
- <option value="2">Public</option>
- </select>
- <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
- <input type="submit" value="Add to virtual shelf" class="submit" />
-</form>
-
-<p align="center">
- <br /><br />
- <a href="javascript:closePopup();">close this window.</a>
-</p>
-
-<script type="text/javascript" language="javascript">
- function closePopup () {
- window.close();
- }
-</script>
-
-</body>
-</html>
--- /dev/null
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<!-- TMPL_VAR NAME="LibraryNameTitle" --> Catalog -- Add to My Book List
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
+
+
+<!-- TMPL_IF NAME="multiple"-->
+ <h1>Add these <!-- TMPL_VAR NAME="total"--> biblios to a shelf</h1>
+ <!-- TMPL_LOOP NAME="biblios"-->
+ <b><!-- TMPL_VAR NAME="title"--></b>
+ <!-- TMPL_IF NAME="author"-->by <!-- TMPL_VAR NAME="author"--><!-- /TMPL_IF -->
+ <br /><br />
+ <!-- /TMPL_LOOP -->
+<!-- TMPL_ELSE -->
+<h1>Add
+ <i><!-- TMPL_VAR NAME="title" --></i>
+ <!-- TMPL_IF NAME="author" -->
+ by <!-- TMPL_VAR NAME="author" -->
+ <!-- /TMPL_IF --> to a Virtual Shelf
+</h1>
+<!-- /TMPL_IF -->
+
+<!-- TMPL_IF NAME="CGIbookshelves"-->
+<form name="f1" action="/cgi-bin/koha/opac-addbookbybiblionumber.pl" method="post">
+ <p><b>Select an Existing Bookshelf</b></p>
+ <label>Add to virtual shelf</label> <!-- TMPL_VAR NAME="CGIbookshelves" -->
+ <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
+ <input type="hidden" name="modifyshelfcontents" value="1" />
+ <input type="submit" value="Add to virtual shelf" class="submit" />
+</form>
+<p>...or...</p>
+<!-- /TMPL_IF -->
+
+<form name="f2" method="post" action="/cgi-bin/koha/opac-addbookbybiblionumber.pl">
+ <b>Add to a New Bookshelf:</b>
+ <p>
+ <label for="newbookshelf">
+ Shelf Name:
+ </label>
+ <input type="text" name="newbookshelf" id="newbookshelf" size="40" />
+ </p>
+ <label for="category">Category:</label>
+ <select name="category" id="category">
+ <option value="1">Private</option>
+ <option value="2">Public</option>
+ </select>
+ <input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
+ <input type="submit" value="Add to virtual shelf" class="submit" />
+</form>
+
+<p align="center">
+ <br /><br />
+ <a href="javascript:closePopup();">close this window.</a>
+</p>
+
+<script type="text/javascript" language="javascript">
+ function closePopup () {
+ window.close();
+ }
+</script>
+
+</body>
+</html>
+++ /dev/null
-#!/usr/bin/perl
-
-#script to provide bookshelf management
-# WARNING: This file uses 4-character tabs!
-#
-# $Header$
-#
-# Copyright 2000-2002 Katipo Communications
-#
-# This file is part of Koha.
-#
-# Koha is free software; you can redistribute it and/or modify it under the
-# terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 2 of the License, or (at your option) any later
-# version.
-#
-# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
-# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License along with
-# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
-# Suite 330, Boston, MA 02111-1307 USA
-
-use strict;
-use C4::Biblio;
-use CGI;
-use C4::BookShelves;
-use C4::Circulation;
-use C4::Auth;
-use C4::Output;
-
-my $query = new CGI;
-my $biblionumber = $query->param('biblionumber');
-my $shelfnumber = $query->param('shelfnumber');
-my $newbookshelf = $query->param('newbookshelf');
-my $category = $query->param('category');
-
-my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
- {
- template_name => "opac-addbookbybiblionumber.tmpl",
- query => $query,
- type => "opac",
- authnotrequired => 1,
- }
-);
-
-$shelfnumber = AddShelf( '', $newbookshelf, $loggedinuser, $category ) if $newbookshelf;
-
-# to know if we had to add more than one biblio.
-my $multiple = 0;
-$multiple = 1 if $biblionumber =~ /^(\d*\/)*$/;
-
-
-if ($shelfnumber) {
-
- if ($multiple){
- foreach (split /\//,$biblionumber){
- &AddToShelfFromBiblio($_,$shelfnumber);
- }
- }
- else {
- &AddToShelfFromBiblio( $biblionumber, $shelfnumber );
- }
- print $query->header;
- print "<html><body onload=\"window.close();\"></body></html>";
- exit;
-}
-else {
- my ($shelflist) = GetShelves( $loggedinuser, 3 );
- my @shelvesloop;
- my %shelvesloop;
- foreach my $element ( sort keys %$shelflist ) {
- push( @shelvesloop, $element );
- $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
- }
-
- my $CGIbookshelves;
- if ( @shelvesloop > 0 ) {
- $CGIbookshelves = CGI::scrolling_list (
- -name => 'shelfnumber',
- -values => \@shelvesloop,
- -labels => \%shelvesloop,
- -size => 1,
- -tabindex => '',
- -multiple => 0
- );
- }
-
- if ( $multiple ) {
- my @biblios;
- foreach (split /\//,$biblionumber){
- my $data = GetBiblioData($_);
- push @biblios,$data;
- }
- $template->param (
- multiple => 1,
- biblionumber => $biblionumber,
- total => scalar @biblios,
- biblios => \@biblios,
- );
- }
- else { # just one to add.
- my $data = GetBiblioData( $biblionumber );
- $template->param (
- biblionumber => $biblionumber,
- title => $data->{'title'},
- author => $data->{'author'},
- );
- }
-
- $template->param (
- CGIbookshelves => $CGIbookshelves,
- );
-
- output_html_with_http_headers $query, $cookie, $template->output;
-}
--- /dev/null
+#!/usr/bin/perl
+
+#script to provide bookshelf management
+# WARNING: This file uses 4-character tabs!
+#
+# $Header$
+#
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+use strict;
+use C4::Biblio;
+use CGI;
+use C4::BookShelves;
+use C4::Circulation;
+use C4::Auth;
+use C4::Output;
+
+my $query = new CGI;
+my $biblionumber = $query->param('biblionumber');
+my $shelfnumber = $query->param('shelfnumber');
+my $newbookshelf = $query->param('newbookshelf');
+my $category = $query->param('category');
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "opac-addbookbybiblionumber.tmpl",
+ query => $query,
+ type => "opac",
+ authnotrequired => 1,
+ }
+);
+
+$shelfnumber = AddShelf( '', $newbookshelf, $loggedinuser, $category ) if $newbookshelf;
+
+# to know if we had to add more than one biblio.
+my $multiple = 0;
+$multiple = 1 if $biblionumber =~ /^(\d*\/)*$/;
+
+
+if ($shelfnumber) {
+
+ if ($multiple){
+ foreach (split /\//,$biblionumber){
+ &AddToShelfFromBiblio($_,$shelfnumber);
+ }
+ }
+ else {
+ &AddToShelfFromBiblio( $biblionumber, $shelfnumber );
+ }
+ print $query->header;
+ print "<html><body onload=\"window.close();\"></body></html>";
+ exit;
+}
+else {
+ my ($shelflist) = GetShelves( $loggedinuser, 3 );
+ my @shelvesloop;
+ my %shelvesloop;
+ foreach my $element ( sort keys %$shelflist ) {
+ push( @shelvesloop, $element );
+ $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
+ }
+
+ my $CGIbookshelves;
+ if ( @shelvesloop > 0 ) {
+ $CGIbookshelves = CGI::scrolling_list (
+ -name => 'shelfnumber',
+ -values => \@shelvesloop,
+ -labels => \%shelvesloop,
+ -size => 1,
+ -tabindex => '',
+ -multiple => 0
+ );
+ }
+
+ if ( $multiple ) {
+ my @biblios;
+ foreach (split /\//,$biblionumber){
+ my $data = GetBiblioData($_);
+ push @biblios,$data;
+ }
+ $template->param (
+ multiple => 1,
+ biblionumber => $biblionumber,
+ total => scalar @biblios,
+ biblios => \@biblios,
+ );
+ }
+ else { # just one to add.
+ my $data = GetBiblioData( $biblionumber );
+ $template->param (
+ biblionumber => $biblionumber,
+ title => $data->{'title'},
+ author => $data->{'author'},
+ );
+ }
+
+ $template->param (
+ CGIbookshelves => $CGIbookshelves,
+ );
+
+ output_html_with_http_headers $query, $cookie, $template->output;
+}
+++ /dev/null
-#!/usr/bin/perl
-
-#
-# This file is a test script for C4::BookShelves.pm
-# Author : Antoine Farnault, antoine@koha-fr.org
-#
-
-use Test;
-use strict;
-use C4::Context;
-
-# Making 30 tests.
-BEGIN { plan tests => 30 }
-
-# Getting some borrowers from database.
-my $dbh = C4::Context->dbh;
-my $query = qq/
- SELECT borrowernumber
- FROM borrowers
- LIMIT 10
-/;
-my $sth = $dbh->prepare($query);
-$sth->execute;
-my @borrowers;
-while(my $borrower = $sth->fetchrow){
- push @borrowers, $borrower;
-}
-
-# Getting some itemnumber from database
-my $query = qq/
- SELECT itemnumber
- FROM items
- LIMIT 10
-/;
-my $sth = $dbh->prepare($query);
-$sth->execute;
-my @items;
-while(my $item = $sth->fetchrow){
- push @items, $item;
-}
-
-# Getting some biblionumbers from database
-my $query = qq/
- SELECT biblionumber
- FROM biblio
- LIMIT 10
-/;
-my $sth = $dbh->prepare($query);
-$sth->execute;
-my @biblionumbers;
-while(my $biblionumber = $sth->fetchrow){
- push @biblionumbers, $biblionumber;
-}
-
-# ---
-my $delete_bookshelf = qq/
- DELETE FROM bookshelf WHERE 1
-/;
-my $delete_bookshelfcontent =qq/
- DELETE FROM shelfcontents WHERE 1
-/;
-
-my $sth = $dbh->prepare($delete_bookshelf);
-$sth->execute;
-my $sth = $dbh->prepare($delete_bookshelfcontent);
-$sth->execute;
-# ---
-
-#----------------------------------------------------------------------#
-#
-# TESTS START HERE
-#
-#----------------------------------------------------------------------#
-
-use C4::BookShelves;
-my $version = C4::BookShelves->VERSION;
-print "\n----------Testing C4::BookShelves version ".$version."--------\n";
-
-ok($version); # First test: the module is loaded & the version is readable.
-
-
-#-----------------------TEST AddShelf function------------------------#
-# usage : $shelfnumber = &AddShelf( $shelfname, $owner, $category);
-
-# creating 10 good shelves.
-my @shelves;
-for(my $i=0; $i<10;$i++){
- my $ShelfNumber = AddShelf("Shelf_".$i,$borrowers[$i],int(rand(3))+1);
- die "test Not ok, remove some shelves before" if ($ShelfNumber == -1);
- ok($ShelfNumber); # Shelf creation successful;
- push @shelves, $ShelfNumber if ok($ShelfNumber);
-}
-
-ok(10,scalar @shelves); # 10 shelves in @shelves;
-
-# try to create some shelf which already exists.
-for(my $i=0;$i<10;$i++){
- my $badNumShelf = AddShelf("Shelf_".int(rand(9)),'','');
- ok(-1,$badNumShelf); # AddShelf returns -1 if name already exist.
-}
-
-#-----------TEST AddToShelf & &AddToShelfFromBiblio & GetShelfContents & DelFromShelf functions--------------#
-# usage : &AddToShelf($itemnumber, $shelfnumber);
-# usage : $itemlist = &GetShelfContents($shelfnumber);
-# usage : $itemlist = GetShelfContents($shelfnumber);
-
-for(my $i=0; $i<10;$i++){
- my $item = $items[int(rand(9))];
- my $shelfnumber = $shelves[int(rand(9))];
-
- my $itemlistBefore = GetShelfContents($shelfnumber);
- AddToShelf($item,$shelfnumber);
- my $itemlistAfter = GetShelfContents($shelfnumber);
- ok(scalar @$itemlistBefore,scalar (@$itemlistAfter - 1)); # the item has been successfuly added.
-
-
- # same thing with AddToShelfFromBiblio
- my $biblionumber = $biblionumbers[int(rand(10))];
- &AddToShelfFromBiblio($biblionumber, $shelfnumber);
- my $AfterAgain = GetShelfContents($shelfnumber);
- ok(scalar @$itemlistAfter, scalar (@$AfterAgain -1));
-}
-
-#-----------------------TEST ModShelf & GetShelf functions------------------------#
-# usage : ModShelf($shelfnumber, $shelfname, $owner, $category )
-# usage : (shelfnumber,shelfname,owner,category) = GetShelf($shelfnumber);
-
-for(my $i=0; $i<10;$i++){
- my $rand = int(rand(9));
- my $numA = $shelves[$rand];
- my $nameA = "NewName_".$rand;
- my $ownerA = $borrowers[$rand];
- my $categoryA = int(rand(3))+1;
-
- ModShelf($numA,$nameA,$ownerA,$categoryA);
- my ($numB,$nameB,$ownerB,$categoryB) = GetShelf($numA);
-
- ok($numA,$numB);
- ok($nameA,$nameB);
- ok($ownerB,$ownerA);
- ok($categoryA,$categoryB);
-}
-
-#-----------------------TEST DelShelf & DelFromShelf functions------------------------#
-# usage : ($status) = &DelShelf($shelfnumber);
-# usage : &DelFromShelf( $itemnumber, $shelfnumber);
-
-for(my $i=0; $i<10;$i++){
- my $shelfnumber = $shelves[$i];
- my $status = DelShelf($shelfnumber);
- if($status){
- my $items = GetShelfContents($shelfnumber);
- ok($status,scalar @$items);
- foreach (@$items){ # delete all the item in this shelf
- DelFromShelf($_{'itemnumber'},$shelfnumber);
- }
- ok(DelShelf($shelfnumber));
- }
-}
--- /dev/null
+#!/usr/bin/perl
+
+#
+# This file is a test script for C4::BookShelves.pm
+# Author : Antoine Farnault, antoine@koha-fr.org
+#
+
+use Test;
+use strict;
+use C4::Context;
+
+# Making 30 tests.
+BEGIN { plan tests => 30 }
+
+# Getting some borrowers from database.
+my $dbh = C4::Context->dbh;
+my $query = qq/
+ SELECT borrowernumber
+ FROM borrowers
+ LIMIT 10
+/;
+my $sth = $dbh->prepare($query);
+$sth->execute;
+my @borrowers;
+while(my $borrower = $sth->fetchrow){
+ push @borrowers, $borrower;
+}
+
+# Getting some itemnumber from database
+my $query = qq/
+ SELECT itemnumber
+ FROM items
+ LIMIT 10
+/;
+my $sth = $dbh->prepare($query);
+$sth->execute;
+my @items;
+while(my $item = $sth->fetchrow){
+ push @items, $item;
+}
+
+# Getting some biblionumbers from database
+my $query = qq/
+ SELECT biblionumber
+ FROM biblio
+ LIMIT 10
+/;
+my $sth = $dbh->prepare($query);
+$sth->execute;
+my @biblionumbers;
+while(my $biblionumber = $sth->fetchrow){
+ push @biblionumbers, $biblionumber;
+}
+
+# ---
+my $delete_bookshelf = qq/
+ DELETE FROM bookshelf WHERE 1
+/;
+my $delete_bookshelfcontent =qq/
+ DELETE FROM shelfcontents WHERE 1
+/;
+
+my $sth = $dbh->prepare($delete_bookshelf);
+$sth->execute;
+my $sth = $dbh->prepare($delete_bookshelfcontent);
+$sth->execute;
+# ---
+
+#----------------------------------------------------------------------#
+#
+# TESTS START HERE
+#
+#----------------------------------------------------------------------#
+
+use C4::BookShelves;
+my $version = C4::BookShelves->VERSION;
+print "\n----------Testing C4::BookShelves version ".$version."--------\n";
+
+ok($version); # First test: the module is loaded & the version is readable.
+
+
+#-----------------------TEST AddShelf function------------------------#
+# usage : $shelfnumber = &AddShelf( $shelfname, $owner, $category);
+
+# creating 10 good shelves.
+my @shelves;
+for(my $i=0; $i<10;$i++){
+ my $ShelfNumber = AddShelf("Shelf_".$i,$borrowers[$i],int(rand(3))+1);
+ die "test Not ok, remove some shelves before" if ($ShelfNumber == -1);
+ ok($ShelfNumber); # Shelf creation successful;
+ push @shelves, $ShelfNumber if ok($ShelfNumber);
+}
+
+ok(10,scalar @shelves); # 10 shelves in @shelves;
+
+# try to create some shelf which already exists.
+for(my $i=0;$i<10;$i++){
+ my $badNumShelf = AddShelf("Shelf_".int(rand(9)),'','');
+ ok(-1,$badNumShelf); # AddShelf returns -1 if name already exist.
+}
+
+#-----------TEST AddToShelf & &AddToShelfFromBiblio & GetShelfContents & DelFromShelf functions--------------#
+# usage : &AddToShelf($itemnumber, $shelfnumber);
+# usage : $itemlist = &GetShelfContents($shelfnumber);
+# usage : $itemlist = GetShelfContents($shelfnumber);
+
+for(my $i=0; $i<10;$i++){
+ my $item = $items[int(rand(9))];
+ my $shelfnumber = $shelves[int(rand(9))];
+
+ my $itemlistBefore = GetShelfContents($shelfnumber);
+ AddToShelf($item,$shelfnumber);
+ my $itemlistAfter = GetShelfContents($shelfnumber);
+ ok(scalar @$itemlistBefore,scalar (@$itemlistAfter - 1)); # the item has been successfuly added.
+
+
+ # same thing with AddToShelfFromBiblio
+ my $biblionumber = $biblionumbers[int(rand(10))];
+ &AddToShelfFromBiblio($biblionumber, $shelfnumber);
+ my $AfterAgain = GetShelfContents($shelfnumber);
+ ok(scalar @$itemlistAfter, scalar (@$AfterAgain -1));
+}
+
+#-----------------------TEST ModShelf & GetShelf functions------------------------#
+# usage : ModShelf($shelfnumber, $shelfname, $owner, $category )
+# usage : (shelfnumber,shelfname,owner,category) = GetShelf($shelfnumber);
+
+for(my $i=0; $i<10;$i++){
+ my $rand = int(rand(9));
+ my $numA = $shelves[$rand];
+ my $nameA = "NewName_".$rand;
+ my $ownerA = $borrowers[$rand];
+ my $categoryA = int(rand(3))+1;
+
+ ModShelf($numA,$nameA,$ownerA,$categoryA);
+ my ($numB,$nameB,$ownerB,$categoryB) = GetShelf($numA);
+
+ ok($numA,$numB);
+ ok($nameA,$nameB);
+ ok($ownerB,$ownerA);
+ ok($categoryA,$categoryB);
+}
+
+#-----------------------TEST DelShelf & DelFromShelf functions------------------------#
+# usage : ($status) = &DelShelf($shelfnumber);
+# usage : &DelFromShelf( $itemnumber, $shelfnumber);
+
+for(my $i=0; $i<10;$i++){
+ my $shelfnumber = $shelves[$i];
+ my $status = DelShelf($shelfnumber);
+ if($status){
+ my $items = GetShelfContents($shelfnumber);
+ ok($status,scalar @$items);
+ foreach (@$items){ # delete all the item in this shelf
+ DelFromShelf($_{'itemnumber'},$shelfnumber);
+ }
+ ok(DelShelf($shelfnumber));
+ }
+}
--- /dev/null
+#!/usr/bin/perl
+
+#script to provide virtual shelf management
+#
+#
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+# $Id$
+
+=head1 NAME
+
+ addvirtualbybiblionumber.pl
+
+=head1 DESCRIPTION
+
+ This script allow to add a virtual in a virtual shelf from a biblionumber.
+
+=head1 CGI PARAMETERS
+
+=over 4
+
+=item biblionumber
+
+ The biblionumber
+
+=item shelfnumber
+
+ the shelfnumber where to add the virtual.
+
+=item newvirtualshelf
+
+ if this parameter exists, then it must be equals to the name of the shelf
+ to add.
+
+=item category
+
+ if this script has to add a shelf, it add one with this category.
+
+=back
+
+=cut
+
+use strict;
+use C4::Biblio;
+use CGI;
+use C4::Output;
+use C4::BookShelves;
+use C4::Circulation;
+use C4::Auth;
+
+
+#use it only to debug !
+use CGI::Carp qw/fatalsToBrowser/;
+use warnings;
+
+my $query = new CGI;
+my $biblionumber = $query->param('biblionumber');
+my $shelfnumber = $query->param('shelfnumber');
+my $newvirtualshelf = $query->param('newvirtualshelf');
+my $category = $query->param('category');
+
+my ($template, $loggedinuser, $cookie)
+= get_template_and_user({template_name => "virtualshelves/addvirtualbybiblionumber.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => {catalogue => 1},
+ });
+
+$shelfnumber = AddShelf($newvirtualshelf,$loggedinuser,$category) if $newvirtualshelf;
+
+if ($shelfnumber || ($shelfnumber == -1)) { # the shelf already exist.
+ &AddToShelfFromBiblio($biblionumber, $shelfnumber);
+ print "Content-Type: text/html\n\n<html><body onload=\"window.close()\"></body></html>";
+ exit;
+} else { # this shelf doesn't already exist.
+ my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
+
+ my ($shelflist) = GetShelves($loggedinuser,3);
+ my @shelvesloop;
+ my %shelvesloop;
+ foreach my $element (sort keys %$shelflist) {
+ push (@shelvesloop, $element);
+ $shelvesloop{$element} = $shelflist->{$element}->{'shelfname'};
+ }
+
+ my $CGIvirtualshelves=CGI::scrolling_list(
+ -name => 'shelfnumber',
+ -values => \@shelvesloop,
+ -labels => \%shelvesloop,
+ -size => 1,
+ -tabindex=>'',
+ -multiple => 0 );
+
+ $template->param(
+ biblionumber => $biblionumber,
+ title => $biblios[0]->{'title'},
+ author => $biblios[0]->{'author'},
+ CGIvirtualshelves => $CGIvirtualshelves,
+ intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+ intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+ IntranetNav => C4::Context->preference("IntranetNav"),
+ );
+
+ output_html_with_http_headers $query, $cookie, $template->output;
+}
+
+# $Log$
+# Revision 1.8 2007/04/24 13:54:29 hdl
+# functions that were in C4::Interface::CGI::Output are now in C4::Output.
+# So this implies quite a change for files.
+# Sorry about conflicts which will be caused.
+# directory Interface::CGI should now be dropped.
+# I noticed that many scripts (reports ones, but also some circ/stats.pl or opac-topissues) still use Date::Manip.
+#
+# Revision 1.7 2007/04/04 16:46:22 tipaul
+# HUGE COMMIT : code cleaning circulation.
+#
+# some stuff to do, i'll write a mail on koha-devel NOW !
+#
+# Revision 1.6 2007/03/09 14:32:26 tipaul
+# rel_3_0 moved to HEAD
+#
+# Revision 1.4.2.6 2006/12/18 16:35:17 toins
+# removing use HTML::Template from *.pl.
+#
+# Revision 1.4.2.5 2006/12/05 11:35:29 toins
+# Biblio.pm cleaned.
+# additionalauthors, bibliosubject, bibliosubtitle tables are now unused.
+# Some functions renamed according to the coding guidelines.
+#
+# Revision 1.4.2.4 2006/11/30 18:23:51 toins
+# theses scripts don't need to use C4::Search.
+#
+# Revision 1.4.2.3 2006/10/30 09:48:19 tipaul
+# samll bugfix to create a virtualshelf correctly
+#
+# Revision 1.4.2.2 2006/08/30 16:13:54 toins
+# correct an error in the "if condition".
+#
+# Revision 1.4.2.1 2006/08/30 15:59:14 toins
+# Code cleaned according to coding guide lines.
+#
+# Revision 1.4 2006/07/04 14:36:51 toins
+# Head & rel_2_2 merged
+#
+# Revision 1.3.2.4 2006/06/20 16:21:42 oleonard
+# Adding "tabindex=''" to CGI:scrolling_lists to prevent incorrect tabbing. See Bug 1098
+#
+# Revision 1.3.2.3 2006/02/05 21:59:21 kados
+# Adds script support for IntranetNav ... see mail to koha-devel for
+# details
+#
+# Revision 1.3.2.2 2006/02/05 21:45:25 kados
+# Adds support for intranetstylesheet system pref in Koha scripts
+#
+
+# Local Variables:
+# tab-width: 4
+# End:
--- /dev/null
+#!/usr/bin/perl
+
+#
+# Copyright 2000-2002 Katipo Communications
+#
+# This file is part of Koha.
+#
+# Koha is free software; you can redistribute it and/or modify it under the
+# terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 2 of the License, or (at your option) any later
+# version.
+#
+# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
+# A PARTICULAR PURPOSE. See the GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License along with
+# Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
+# Suite 330, Boston, MA 02111-1307 USA
+
+=head1 NAME
+
+ shelves.pl
+
+=head1 DESCRIPTION
+
+ this script is used to script to provide bookshelf management
+
+=head1 CGI PARAMETERS
+
+=over 4
+
+=item C<modifyshelfcontents>
+
+ if this script has to modify the shelve content.
+
+=item C<shelfnumber>
+
+ to know on which shelve this script has to work.
+
+=item C<addbarcode>
+
+=item C<op>
+
+ op can be equals to:
+ * modifsave to save change on the shelves
+ * modif to change the template to allow to modify the shelves.
+
+=item C<viewshelf>
+
+ to load the template with 'viewshelves param' which allow to read the shelves information.
+
+=item C<shelves>
+
+ if equals to 1. then call the function shelves which add
+ or delete a shelf.
+
+=item C<addshelf>
+
+ if the param shelves = 1 then addshelf must be equals to the name of the shelf to add.
+
+=back
+
+=cut
+
+use strict;
+use CGI;
+use C4::BookShelves;
+use C4::Biblio;
+use C4::Auth;
+use C4::Output;
+
+my $query = new CGI;
+
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+ {
+ template_name => "bookshelves/shelves.tmpl",
+ query => $query,
+ type => "intranet",
+ authnotrequired => 0,
+ flagsrequired => { catalogue => 1 },
+ }
+);
+
+if ( $query->param('modifyshelfcontents') ) {
+ my $shelfnumber = $query->param('viewshelf');
+ my $barcode = $query->param('addbarcode');
+ my ($item) = GetItem( 0, $barcode );
+ if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ) ) {
+ AddToShelf( $item->{'itemnumber'}, $shelfnumber );
+ foreach ( $query->param ) {
+ if (/REM-(\d*)/) {
+ my $itemnumber = $1;
+ DelFromShelf( $itemnumber, $shelfnumber );
+ }
+ }
+ }
+}
+
+# getting the Shelves list
+my $shelflist = GetShelves( $loggedinuser, 2 );
+$template->param( { loggedinuser => $loggedinuser } );
+my $op = $query->param('op');
+
+SWITCH: {
+ if ( $op && ( $op eq 'modifsave' ) ) {
+ ModShelf(
+ $query->param('shelfnumber'), $query->param('shelfname'),
+ $loggedinuser, $query->param('category')
+ );
+ last SWITCH;
+ }
+ if ( $op && ( $op eq 'modif' ) ) {
+ my ( $shelfnumber, $shelfname, $owner, $category ) =
+ GetShelf( $query->param('shelf') );
+ $template->param(
+ edit => 1,
+ shelfnumber => $shelfnumber,
+ shelfname => $shelfname,
+ "category$category" => 1
+ );
+
+ # editshelf($query->param('shelf'));
+ last SWITCH;
+ }
+ if ( $query->param('viewshelf') ) {
+ #check that the user can view the shelf
+ my $shelfnumber = $query->param('viewshelf');
+ if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) ) {
+ my $items = GetShelfContents($shelfnumber);
+ $template->param(
+ shelfname => $shelflist->{$shelfnumber}->{'shelfname'},
+ shelfnumber => $shelfnumber,
+ viewshelf => $query->param('viewshelf'),
+ manageshelf => &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ),
+ itemsloop => $items,
+ );
+ }
+ last SWITCH;
+ }
+ if ( $query->param('shelves') ) {
+ if ( my $newshelf = $query->param('addshelf') ) {
+ my $shelfnumber = AddShelf(
+ $newshelf,
+ $query->param('owner'),
+ $query->param('category')
+ );
+
+ if ( $shelfnumber == -1 ) { #shelf already exists.
+ $template->param(
+ {
+ shelfnumber => $shelfnumber,
+ already => 1
+ }
+ );
+ }
+ }
+ my @paramsloop;
+ foreach ( $query->param() ) {
+ my %line;
+ if (/DEL-(\d+)/) {
+ my $delshelf = $1;
+ my ( $status, $count ) = DelShelf($delshelf);
+ if ($status) {
+ $line{'status'} = $status;
+ $line{'count'} = $count;
+ }
+ }
+
+ #if the shelf is not deleted, %line points on null
+ push( @paramsloop, \%line );
+ }
+ $template->param( paramsloop => \@paramsloop );
+ my ($shelflist) = GetShelves( $loggedinuser, 2 );
+ my $color = '';
+ my @shelvesloop;
+ foreach my $element ( sort keys %$shelflist ) {
+ my %line;
+ ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+ $line{'toggle'} = $color;
+ $line{'shelf'} = $element;
+ $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
+ $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
+ push( @shelvesloop, \%line );
+ }
+ $template->param(
+ shelvesloop => \@shelvesloop,
+ shelves => 1,
+ );
+ last SWITCH;
+ }
+}
+
+($shelflist) =
+ GetShelves( $loggedinuser, 2 )
+ ; # rebuild shelflist in case a shelf has been added
+
+my $color = '';
+my @shelvesloop;
+my $numberCanManage = 0;
+
+foreach my $element ( sort keys %$shelflist ) {
+ my %line;
+ ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+ $line{'toggle'} = $color;
+ $line{'shelf'} = $element;
+ $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
+ $line{ "category" . $shelflist->{$element}->{'category'} } = 1;
+ $line{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser;
+ $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
+ $line{'canmanage'} = ShelfPossibleAction( $loggedinuser, $element, 'manage' );
+ $line{'firstname'} = $shelflist->{$element}->{'firstname'}
+ unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
+ $line{'surname'} = $shelflist->{$element}->{'surname'}
+ unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
+
+ $numberCanManage++ if $line{'canmanage'};
+
+ push( @shelvesloop, \%line );
+}
+
+$template->param(
+ shelvesloop => \@shelvesloop,
+ numberCanManage => $numberCanManage,
+);
+
+output_html_with_http_headers $query, $cookie, $template->output;
+
+sub shelves {
+ my $innertemplate = shift;
+ if ( my $newshelf = $query->param('addshelf') ) {
+ my $shelfnumber = AddShelf(
+ $newshelf,
+ $query->param('owner'),
+ $query->param('category')
+ );
+
+ if ( $shelfnumber == -1 ) { #shelf already exists.
+ $template->param(
+ {
+ shelfnumber => $shelfnumber,
+ already => 1
+ }
+ );
+ }
+ }
+ my @paramsloop;
+ foreach ( $query->param() ) {
+ my %line;
+ if (/DEL-(\d+)/) {
+ my $delshelf = $1;
+ my ( $status, $count ) = DelShelf($delshelf);
+ if ($status) {
+ $line{'status'} = $status;
+ $line{'count'} = $count;
+ }
+ }
+
+ #if the shelf is not deleted, %line points on null
+ push( @paramsloop, \%line );
+ }
+ $innertemplate->param( paramsloop => \@paramsloop );
+ my ($shelflist) = GetShelves( $loggedinuser, 2 );
+ my $color = '';
+ my @shelvesloop;
+ foreach my $element ( sort keys %$shelflist ) {
+ my %line;
+ ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+ $line{'toggle'} = $color;
+ $line{'shelf'} = $element;
+ $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
+ $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
+ push( @shelvesloop, \%line );
+ }
+ $innertemplate->param(
+ shelvesloop => \@shelvesloop,
+ shelves => 1,
+ );
+}
+
+#
+# $Log$
+# Revision 1.13 2007/04/24 13:54:29 hdl
+# functions that were in C4::Interface::CGI::Output are now in C4::Output.
+# So this implies quite a change for files.
+# Sorry about conflicts which will be caused.
+# directory Interface::CGI should now be dropped.
+# I noticed that many scripts (reports ones, but also some circ/stats.pl or opac-topissues) still use Date::Manip.
+#
+# Revision 1.12 2007/04/04 16:46:22 tipaul
+# HUGE COMMIT : code cleaning circulation.
+#
+# some stuff to do, i'll write a mail on koha-devel NOW !
+#
+# Revision 1.11 2007/03/09 14:32:26 tipaul
+# rel_3_0 moved to HEAD
+#
+# Revision 1.9.2.9 2007/02/05 15:54:30 toins
+# don't display "remove selected shelves" if the user logged has no shelf.
+#
+# Revision 1.9.2.8 2006/12/15 17:36:57 toins
+# - some change on the html param.
+# - Writing directly the code of a sub called only once.
+# - adding syspref: BiblioDefaultView.
+#
+# Revision 1.9.2.7 2006/12/14 17:22:55 toins
+# bookshelves work perfectly with mod_perl and are cleaned.
+#
+# Revision 1.9.2.6 2006/12/13 10:06:05 toins
+# fix a mod_perl specific bug.
+#
+# Revision 1.9.2.5 2006/12/11 17:10:06 toins
+# fixing some bugs on bookshelves.
+#
+# Revision 1.9.2.4 2006/11/30 18:23:51 toins
+# theses scripts don't need to use C4::Search.
+#
+# Revision 1.9.2.3 2006/10/30 09:50:45 tipaul
+# better perl writting
+#
+# Revision 1.9.2.2 2006/10/17 07:59:35 toins
+# ccode added.
+#