[Koha-cvs] koha C4/BookShelves.pm bookshelves/shelves.pl k... [rel_3_0]

Antoine Farnault antoine at koha-fr.org
Mon Dec 11 18:10:06 CET 2006


CVSROOT:	/sources/koha
Module name:	koha
Branch:		rel_3_0
Changes by:	Antoine Farnault <toins>	06/12/11 17:10:06

Modified files:
	C4             : BookShelves.pm 
	bookshelves    : shelves.pl 
	koha-tmpl/intranet-tmpl/prog/en/bookshelves: 
	                                             addbookbybiblionumber.tmpl 
	                                             shelves.tmpl 
	koha-tmpl/opac-tmpl/prog/en: opac-addbookbybiblionumber.tmpl 
	                             opac-shelves.tmpl 
	opac           : opac-addbookbybiblionumber.pl opac-shelves.pl 

Log message:
	fixing some bugs on bookshelves.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/koha/C4/BookShelves.pm?cvsroot=koha&only_with_tag=rel_3_0&r1=1.15.8.5&r2=1.15.8.6
http://cvs.savannah.gnu.org/viewcvs/koha/bookshelves/shelves.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.9.2.4&r2=1.9.2.5
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/bookshelves/addbookbybiblionumber.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.3&r2=1.1.2.4
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/intranet-tmpl/prog/en/bookshelves/shelves.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.9&r2=1.1.2.10
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/opac-tmpl/prog/en/opac-addbookbybiblionumber.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.1&r2=1.1.2.2
http://cvs.savannah.gnu.org/viewcvs/koha/koha-tmpl/opac-tmpl/prog/en/opac-shelves.tmpl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.1.2.3&r2=1.1.2.4
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-addbookbybiblionumber.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.5.2.3&r2=1.5.2.4
http://cvs.savannah.gnu.org/viewcvs/koha/opac/opac-shelves.pl?cvsroot=koha&only_with_tag=rel_3_0&r1=1.8.2.4&r2=1.8.2.5

Patches:
Index: C4/BookShelves.pm
===================================================================
RCS file: /sources/koha/koha/C4/BookShelves.pm,v
retrieving revision 1.15.8.5
retrieving revision 1.15.8.6
diff -u -b -r1.15.8.5 -r1.15.8.6
--- C4/BookShelves.pm	7 Dec 2006 16:45:43 -0000	1.15.8.5
+++ C4/BookShelves.pm	11 Dec 2006 17:10:06 -0000	1.15.8.6
@@ -3,7 +3,7 @@
 
 package C4::BookShelves;
 
-# $Id: BookShelves.pm,v 1.15.8.5 2006/12/07 16:45:43 toins Exp $
+# $Id: BookShelves.pm,v 1.15.8.6 2006/12/11 17:10:06 toins Exp $
 
 # Copyright 2000-2002 Katipo Communications
 #
@@ -24,13 +24,12 @@
 
 use strict;
 require Exporter;
-use DBI;
 use C4::Context;
 use C4::Circulation::Circ2;
 use vars qw($VERSION @ISA @EXPORT);
 
 # set the version for version checking
-$VERSION = do { my @v = '$Revision: 1.15.8.5 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
+$VERSION = do { my @v = '$Revision: 1.15.8.6 $' =~ /\d+/g; shift(@v) . "." . join( "_", map { sprintf "%03d", $_ } @v ); };
 
 =head1 NAME
 
@@ -223,7 +222,6 @@
     }
 }
 
-
 =item AddToShelf
 
   &AddToShelf($itemnumber, $shelfnumber);
@@ -286,7 +284,7 @@
     $sth = $dbh->prepare($query);
     $sth->execute( $shelfnumber, $itemnumber );
     unless ( $sth->rows ) {
-        # already on shelf
+        # "already on shelf";
         my $query =qq(
             INSERT INTO shelfcontents
                 (shelfnumber, itemnumber, flags)
@@ -333,19 +331,15 @@
 
 =item ShelfPossibleAction
 
-=over 4
-
 ShelfPossibleAction($loggedinuser, $shelfnumber, $action);
 
-=item C<$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.
 
-=back
-
 =cut
 
 sub ShelfPossibleAction {
@@ -376,6 +370,7 @@
 #'
 sub DelFromShelf {
     my ( $itemnumber, $shelfnumber ) = @_;
+    warn Data::Dumper::Dumper(@_);
     my $query = qq(
         DELETE FROM shelfcontents
         WHERE  shelfnumber=? AND itemnumber=?
@@ -394,6 +389,7 @@
 
 #'
 sub DelShelf {
+    warn "Delshelf";
     my ( $shelfnumber ) = @_;
         my $sth = $dbh->prepare("DELETE FROM bookshelf WHERE shelfnumber=?");
         $sth->execute($shelfnumber);
@@ -404,8 +400,25 @@
 
 1;
 
+__END__
+
+=back
+
+=head1 AUTHOR
+
+Koha Developement team <info at koha.org>
+
+=head1 SEE ALSO
+
+C4::Circulation::Circ2(3)
+
+=cut
+
 #
 # $Log: BookShelves.pm,v $
+# 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)
 #
@@ -430,17 +443,3 @@
 # adding bookshelf features :
 # * create bookshelf on the fly
 # * modify a bookshelf (this being not finished, will commit the rest soon)
-
-__END__
-
-=back
-
-=head1 AUTHOR
-
-Koha Developement team <info at koha.org>
-
-=head1 SEE ALSO
-
-C4::Circulation::Circ2(3)
-
-=cut

Index: bookshelves/shelves.pl
===================================================================
RCS file: /sources/koha/koha/bookshelves/shelves.pl,v
retrieving revision 1.9.2.4
retrieving revision 1.9.2.5
diff -u -b -r1.9.2.4 -r1.9.2.5
--- bookshelves/shelves.pl	30 Nov 2006 18:23:51 -0000	1.9.2.4
+++ bookshelves/shelves.pl	11 Dec 2006 17:10:06 -0000	1.9.2.5
@@ -18,7 +18,6 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
-
 =head1 NAME
 
     shelves.pl
@@ -71,159 +70,184 @@
 use C4::Circulation::Circ2;
 use C4::Auth;
 use C4::Interface::CGI::Output;
-use HTML::Template;
 
 my $query = new CGI;
 
-my ($template, $loggedinuser, $cookie)
-    = get_template_and_user({template_name => "bookshelves/shelves.tmpl",
+my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
+    {
+        template_name   => "bookshelves/shelves.tmpl",
 							query => $query,
 							type => "intranet",
 							authnotrequired => 0,
-							flagsrequired => {catalogue => 1},
-						});
+        flagsrequired   => { catalogue => 1 },
+    }
+);
 
-if ($query->param('modifyshelfcontents')) {
-	my $shelfnumber=$query->param('shelfnumber');
-	my $barcode=$query->param('addbarcode');
-	my ($item) = getiteminformation(0, $barcode);
-	if (ShelfPossibleAction($loggedinuser,$shelfnumber,'manage')) {
-		AddToShelf($item->{'itemnumber'}, $shelfnumber);
-		foreach ($query->param) {
+if ( $query->param('modifyshelfcontents') ) {
+    my $shelfnumber = $query->param('shelfnumber');
+    my $barcode     = $query->param('addbarcode');
+    my ($item) = getiteminformation( 0, $barcode );
+    if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ) ) {
+        AddToShelf( $item->{'itemnumber'}, $shelfnumber );
+        foreach ( $query->param ) {
 			if (/REM-(\d*)/) {
-				my $itemnumber=$1;
-				DelFromShelf($itemnumber, $shelfnumber);
+                my $itemnumber = $1;
+                DelFromShelf( $itemnumber, $shelfnumber );
 			}
 		}
 	}
 }
 
 # getting the Shelves list
-my $shelflist = GetShelves($loggedinuser,2);
-
-$template->param({loggedinuser => $loggedinuser});
+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'));
+    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,
+    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'));
+            "category$category" => 1
+        );
+
+        #         editshelf($query->param('shelf'));
 		last SWITCH;
 	}
-	if ($query->param('viewshelf')) {
-		viewshelf($query->param('viewshelf'));
+    if ( $query->param('viewshelf') ) {
+        viewshelf( $query->param('viewshelf') );
 		last SWITCH;
 	}
-	if ($query->param('shelves')) {
+    if ( $query->param('shelves') ) {
 		shelves();
 		last SWITCH;
 	}
 }
 
-($shelflist) = GetShelves($loggedinuser,2); # rebuild shelflist in case a shelf has been added
+($shelflist) =
+  GetShelves( $loggedinuser, 2 )
+  ;    # rebuild shelflist in case a shelf has been added
 
-my $color='';
+my $color = '';
 my @shelvesloop;
-foreach my $element (sort keys %$shelflist) {
+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;
+    ( $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;
-
-		push (@shelvesloop, \%line);
-		}
+    $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;
+    push( @shelvesloop, \%line );
+}
 $template->param(
         shelvesloop => \@shelvesloop,
-		intranetcolorstylesheet => C4::Context->preference("intranetcolorstylesheet"),
+    intranetcolorstylesheet =>
+      C4::Context->preference("intranetcolorstylesheet"),
 		intranetstylesheet => C4::Context->preference("intranetstylesheet"),
 		IntranetNav => C4::Context->preference("IntranetNav"),
-		);
+);
 
 output_html_with_http_headers $query, $cookie, $template->output;
 
-
 sub shelves {
-	if (my $newshelf=$query->param('addshelf')) {
-		my $shelfnumber = AddShelf($newshelf,$query->param('owner'),$query->param('category'));
+    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,
+        if ( $shelfnumber == -1 ) {    #shelf already exists.
+            $template->param(
+                {
+                    shelfnumber => $shelfnumber,
                 already => 1
-            });
+                }
+            );
 		}
 	}
 	my @paramsloop;
-	foreach ($query->param()) {
+    foreach ( $query->param() ) {
 		my %line;
 		if (/DEL-(\d+)/) {
-			my $delshelf=$1;
-			my ($status, $count) = DelShelf($delshelf);
+            my $delshelf = $1;
+            my ( $status, $count ) = DelShelf($delshelf);
 			if ($status) {
-				$line{'status'}=$status;
+                $line{'status'} = $status;
 				$line{'count'} = $count;
 			}
 		}
+
 		#if the shelf is not deleted, %line points on null
-		push(@paramsloop,\%line);
+        push( @paramsloop, \%line );
 	}
-	$template->param(paramsloop => \@paramsloop);
-	my ($shelflist) = GetShelves($loggedinuser,2);
-	my $color='';
+    $template->param( paramsloop => \@paramsloop );
+    my ($shelflist) = GetShelves( $loggedinuser, 2 );
+    my $color = '';
 	my @shelvesloop;
-	foreach my $element (sort keys %$shelflist) {
+    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);
+        ( $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,
+        shelvesloop => \@shelvesloop,
 			shelves => 1,
 	);
 }
 
 sub viewshelf {
-	my $shelfnumber=shift;
+    my $shelfnumber = shift;
+
 	#check that the user can view the shelf
-	return unless (ShelfPossibleAction($loggedinuser,$shelfnumber,'view'));
+    return
+      unless ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'view' ) );
 	my ($itemlist) = GetShelfContents($shelfnumber);
-	my $item='';
-	my $color='';
+    my $item       = '';
+    my $color      = '';
 	my @itemsloop;
-	foreach $item (sort {$a->{'barcode'} cmp $b->{'barcode'}} @$itemlist) {
-		($color eq 1) ? ($color=0) : ($color=1);
-		$item->{'toggle'}=$color;
-		push(@itemsloop, $item);
+    foreach $item ( sort { $a->{'barcode'} cmp $b->{'barcode'} } @$itemlist ) {
+        ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+        $item->{'toggle'} = $color;
+        push( @itemsloop, $item );
 	}
-	$template->param(	itemsloop => \@itemsloop,
+    $template->param(
+        itemsloop   => \@itemsloop,
 						shelfname => $shelflist->{$shelfnumber}->{'shelfname'},
 						shelfnumber => $shelfnumber,
 						viewshelf => $query->param('viewshelf'),
-						manageshelf => &ShelfPossibleAction($loggedinuser,$shelfnumber,'manage'),
+        manageshelf =>
+          &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ),
 					);
 }
 
 #
 # $Log: shelves.pl,v $
+# 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.
 #

Index: koha-tmpl/intranet-tmpl/prog/en/bookshelves/addbookbybiblionumber.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/bookshelves/addbookbybiblionumber.tmpl,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -b -r1.1.2.3 -r1.1.2.4
--- koha-tmpl/intranet-tmpl/prog/en/bookshelves/addbookbybiblionumber.tmpl	30 Oct 2006 15:08:32 -0000	1.1.2.3
+++ koha-tmpl/intranet-tmpl/prog/en/bookshelves/addbookbybiblionumber.tmpl	11 Dec 2006 17:10:06 -0000	1.1.2.4
@@ -1,20 +1,42 @@
-<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->Koha -- Add to Virtual Shelf<!-- 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>
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+Koha -- Add to Virtual Shelf
+<!-- 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" -->">
-    <fieldset>
-        <legend>Select an Existing Bookshelf</legend>
-        <p><label>Add to virtual shelf</label><!-- TMPL_VAR NAME="CGIbookshelves" --></p>
+    
+    <b>Select an Existing Bookshelf</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" />
-    </fieldset>
-    <p>...or...</p>
-    <fieldset>
-    <legend>Add to a New Bookshelf:</legend>
-        <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">
+</form>
+<p>...or...</p>
+<form name="f2" method="POST" action="/cgi-bin/koha/bookshelves/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>
+        <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>

Index: koha-tmpl/intranet-tmpl/prog/en/bookshelves/shelves.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/intranet-tmpl/prog/en/bookshelves/shelves.tmpl,v
retrieving revision 1.1.2.9
retrieving revision 1.1.2.10
diff -u -b -r1.1.2.9 -r1.1.2.10
--- koha-tmpl/intranet-tmpl/prog/en/bookshelves/shelves.tmpl	23 Nov 2006 09:05:02 -0000	1.1.2.9
+++ koha-tmpl/intranet-tmpl/prog/en/bookshelves/shelves.tmpl	11 Dec 2006 17:10:06 -0000	1.1.2.10
@@ -20,9 +20,30 @@
             <input type="hidden" name="op" value="modifsave" />
             <table>
             <caption>Editing Shelf <!-- TMPL_VAR name="shelfname"--></caption>
-            <tr><td><input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR name="shelfnumber" -->" /><label for="shelfname">Name:</label></td><td><input id="shelfname" type="text" 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">
+            <tr>
+                <td>
+                    <input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR name="shelfnumber" -->" />
+                    <label for="shelfname">Name:</label>
+                </td>
+                <td>
+                    <input id="shelfname" type="text" 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 -->
@@ -38,16 +59,20 @@
                     <!-- TMPL_ELSE -->
                         <option value="3">Free</option>
                     <!-- /TMPL_IF -->
-                </select></td></tr>
+                    </select>
+                </td>
+            </tr>
             </table>
-            <ul><li>a private bookshelf is managed by you and can be seen only by you.</li>
+            <ul>
+                <li>a private bookshelf is managed by you and can be seen only by you.</li>
                 <li> A public can be seen by everybody, but managed only by you.</li>
-                <li> A free can be managed by any user.</li></ul>
+                <li> A free can be managed by any user.</li>
+            </ul>
             <input type="submit" value="Save Changes" /></p>
         </form>
 <!-- /TMPL_IF -->
 
-<!-- TMPL_IF Name="viewshelf" -->
+<!-- TMPL_IF NAME="viewshelf" -->
     <form action="<!-- TMPL_VAR NAME="script_name" -->" method="post" name="mainform">
             <table>
             <caption>Contents of <!-- TMPL_VAR NAME="shelfname" --></caption>
@@ -56,7 +81,13 @@
                     <th>Summary</th>
                     <th>Item Type</th>
                     <th>&nbsp;</th>
-                </tr><!-- TMPL_LOOP Name="itemsloop" --><!-- TMPL_IF NAME="toggle" --><tr class="highlight"><!-- TMPL_ELSE --><tr><!-- /TMPL_IF --><!-- TMPL_IF name="manageshelf" --><td><input type="checkbox" name="REM-<!-- TMPL_VAR NAME="itemnumber" -->" /></td><!-- /TMPL_IF -->
+            </tr>
+                <!-- TMPL_LOOP Name="itemsloop" -->
+                    <!-- TMPL_IF NAME="toggle" -->
+                        <tr class="highlight">
+                    <!-- TMPL_ELSE -->
+                        <tr>
+                    <!-- /TMPL_IF --><!-- TMPL_IF name="manageshelf" --><td><input type="checkbox" name="REM-<!-- TMPL_VAR NAME="itemnumber" -->" /></td><!-- /TMPL_IF -->
                         <td><p><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR name="biblionumber" -->"><!-- TMPL_VAR NAME="title" --></a></p>
                     <p><!-- TMPL_VAR NAME="author" -->
                         <!-- TMPL_IF name="publicationyear" --> - <!-- TMPL_VAR name="publicationyear" --><!-- /TMPL_IF -->
@@ -81,7 +112,7 @@
 
     <!-- TMPL_IF name="manageshelf" -->
         <form>
-<table>
+    <table>
         <caption>Add an item by barcode</caption>
         <tr><th><label for="barcode">Barcode:</label></th><td><input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR NAME="shelfnumber" -->" />
             <input type="hidden" name="modifyshelfcontents" value="1" />
@@ -110,7 +141,9 @@
             <!-- /TMPL_IF -->
         <!-- /TMPL_LOOP -->
                     <form method="post" action="<!-- TMPL_VAR NAME="script_name" -->">
-                    <input type="hidden" name="shelves" value="1" /><table>
+                    <input type="hidden" name="shelves" value="1" />
+                    <!-- TMPL_IF NAME="shelvesloop" -->
+                    <table>
                         <caption>Bookshelves</caption>
                         <th>&nbsp;</th><th>Title</th><th>Item Count</th>
                     <!-- TMPL_LOOP Name="shelvesloop" -->
@@ -127,29 +160,57 @@
                                 </td>
                             </tr>
                         <!-- /TMPL_IF -->
-                        <!-- /TMPL_LOOP --></table>
-                    
+                    <!-- /TMPL_LOOP -->
+                    </table>
                         <input type="submit" value="Delete Selected Shelves" /> <sup>*</sup>Shelves must be empty before they can be deleted.
                     </p>
+                    <!-- TMPL_ELSE -->
+                        <span class="problem">No shelf defined.</span>
+                    <!-- /TMPL_IF -->
                     </form>
 
             <form method="post" action="<!-- TMPL_VAR NAME="script_name" -->">
                 <input type="hidden" name="shelves" value="1" />
                 <table>
                 <caption>Add Shelf</caption>
-                <tr><th><label>Name</label></th><td><input type="text" name="addshelf" size="25" /></td></tr>
-                <tr><th><label>Owner</label></th><td><input type="hidden" name="owner" value="<!-- TMPL_VAR NAME="loggedinuser" -->" /><!-- TMPL_VAR NAME="loggedinusername" --></td></tr>
-                <tr><th><label>Category</label></th>
-                    <td><select name="category">
+                <tr>
+                    <th>
+                        <label>Name</label>
+                    </th>
+                    <td>
+                        <input type="text" name="addshelf" size="25" />
+                    </td>
+                </tr>
+                <tr>
+                    <th>
+                        <label>Owner</label>
+                    </th>
+                    <td>
+                        <input type="hidden" name="owner" value="<!-- TMPL_VAR NAME="loggedinuser" -->" />
+                        <!-- TMPL_VAR NAME="loggedinusername" -->
+                    </td>
+                </tr>
+                <tr>
+                    <th><label>Category</label></th>
+                    <td>
+                        <select name="category">
                         <option value="1">Private</option>
                         <option value="2">Public</option>
-                    </select></td></tr>
-</table>
-<ul><li>A private bookshelf is managed by you and can be seen only by you.</li>
-                    <li> A public shelf can be seen by everybody, but managed only by you.</li></ul>
-                    <input type="submit" value="Add New Shelf" /></form>
-                    <form action="shelves.pl" method="get"><input type="submit" value="Back to Shelf List" /></form>
+                        </select>
+                    </td>
+                </tr>
+            </table>
+        <ul>
+            <li>A private bookshelf is managed by you and can be seen only by you.</li>
+            <li> A public shelf can be seen by everybody, but managed only by you.</li>
+        </ul>
+        <input type="submit" value="Add New Shelf" />
+        </form>
+        <form action="/cgi-bin/koha/bookshelves/shelves.pl" method="POST">
+            <input type="submit" value="Back to Shelf List" />
+        </form>
     <!-- TMPL_ELSE -->
+            <!-- TMPL_IF NAME="shelvesloop" -->
             <table>
             <caption>Existing virtual shelves</caption>
                 <tr>
@@ -160,14 +221,20 @@
                     <th>&nbsp;</th>
                 </tr>
                 <!-- TMPL_LOOP Name="shelvesloop" -->
-                <!-- TMPL_IF NAME="toggle" --><tr class="highlight"><!-- TMPL_ELSE --><tr><!-- /TMPL_IF -->
-                    <td><p>
-                        <a href="shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelf" -->">
+                <!-- TMPL_IF NAME="toggle" -->
+                    <tr class="highlight">
+                <!-- TMPL_ELSE -->
+                    <tr>
+                <!-- /TMPL_IF -->
+                    <td>
+                        <p>
+                            <a href="/cgi-bin/koha/bookshelves/shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelf" -->">
                             <!-- TMPL_VAR NAME="shelfname" -->
                         </a>
                         </p>
                     </td>
-                    <td><p>
+                    <td>
+                        <p>
                         <!-- TMPL_IF NAME="category1" -->
                             Private
                         <!-- /TMPL_IF -->
@@ -186,15 +253,22 @@
                         <p><!-- TMPL_VAR name="firstname" --> <!-- TMPL_VAR name="surname" --></p>
                     <td>
                     <!-- TMPL_IF name="mine" -->
-                        <p><a href="shelves.pl?op=modif&amp;shelf=<!-- TMPL_VAR NAME="shelf" -->">Edit</a></p>
+                        <p>
+                            <a href="shelves.pl?op=modif&amp;shelf=<!-- TMPL_VAR NAME="shelf" -->">
+                                Edit
+                            </a>
+                        </p>
                     <!-- /TMPL_IF -->
                     </td>
                 </tr>
                 <!-- /TMPL_LOOP -->
             </table>
-        <form action="shelves.pl" method="get"><input type="hidden" value="1" name="shelves" /><input type="submit" value="Add or Remove Book Shelves" />				
+             <!-- /TMPL_IF -->
+        <form action="/cgi-bin/koha/bookshelves/shelves.pl" method="POST">
+            <input type="hidden" value="1" name="shelves" />
+            <input type="submit" value="Add or Remove Book Shelves" />
+        </form>
     <!-- /TMPL_IF -->
 <!-- /TMPL_IF -->
 
-
 <!-- TMPL_INCLUDE Name="intranet-bottom.inc" -->

Index: koha-tmpl/opac-tmpl/prog/en/opac-addbookbybiblionumber.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/opac-tmpl/prog/en/opac-addbookbybiblionumber.tmpl,v
retrieving revision 1.1.2.1
retrieving revision 1.1.2.2
diff -u -b -r1.1.2.1 -r1.1.2.2
--- koha-tmpl/opac-tmpl/prog/en/opac-addbookbybiblionumber.tmpl	22 Nov 2006 15:47:30 -0000	1.1.2.1
+++ koha-tmpl/opac-tmpl/prog/en/opac-addbookbybiblionumber.tmpl	11 Dec 2006 17:10:06 -0000	1.1.2.2
@@ -1,24 +1,50 @@
-<!-- TMPL_INCLUDE NAME="doc-head-open.inc" --><!-- TMPL_VAR NAME="LibraryNameTitle" --> Catalog -- Add to My Book List<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
-<div id="window">
-<h3>Add <i><!-- TMPL_VAR NAME="title" --></i> <!-- TMPL_IF NAME="author" -->by <!-- TMPL_VAR NAME="author" --><!-- /TMPL_IF --> to a Book List</h3><form action="/cgi-bin/koha/opac-addbookbybiblionumber.pl" method="post">
+<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
+<!-- TMPL_VAR NAME="LibraryNameTitle" --> Catalog -- Add to My Book List
+<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
 
-<h3>Select a Book List:</h3>
-<p><label for="shelfnumber">Add to Existing List</label> <!-- TMPL_VAR NAME="CGIbookshelves" --></p>
-</form>
-<h4>...or...</h4>
-<form action="/cgi-bin/koha/opac-addbookbybiblionumber.pl" method="post">
+<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" action="/cgi-bin/koha/opac-addbookbybiblionumber.pl" method="GET">
+    
+    <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" />
 
-<h3>Add to a new Book List:</h3>
-<p><label for="newbookshelf">New List Name:</label><input type="text" id="newbookshelf" name="newbookshelf" maxlength="40" size="40">
-	<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->"></p>
-<p><label for="category">List Type: </label></th><td><select id="category" name="category">
+</form>
+<p>...or...</p>
+<form name="f2" method="GET" 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>
-			<option value="3">Free</option>
-		</select></p>
+            </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">
+    <a href="javascript:closePopup();">close this window.</a>
+</p>
 
+<script type="text/javascript" language="javascript">
+    function closePopup () {
+        window.close();
+    }
+</script>
 
-	<p><input type="hidden" name="category" value="1" /><input type="submit" value="Add to My Book List"></p></form>
-</div>
 </body>
 </html>

Index: koha-tmpl/opac-tmpl/prog/en/opac-shelves.tmpl
===================================================================
RCS file: /sources/koha/koha/koha-tmpl/opac-tmpl/prog/en/opac-shelves.tmpl,v
retrieving revision 1.1.2.3
retrieving revision 1.1.2.4
diff -u -b -r1.1.2.3 -r1.1.2.4
--- koha-tmpl/opac-tmpl/prog/en/opac-shelves.tmpl	7 Dec 2006 15:42:15 -0000	1.1.2.3
+++ koha-tmpl/opac-tmpl/prog/en/opac-shelves.tmpl	11 Dec 2006 17:10:06 -0000	1.1.2.4
@@ -11,7 +11,14 @@
 <form class="inline" action="/cgi-bin/koha/opac-shelves.pl" method="post" name="mainform">
     <table>
             <tr>
-            <th><a href="/cgi-bin/koha/opac-shelves.pl" onclick="CheckAll(); return false;"><img src="<!-- TMPL_VAR NAME="themelang" -->/images/checkall.gif" height="18" width="18" alt="Check All" title="Check All" border="0" /></a></th><th>&nbsp;</th><th>Title</th><th>Author</th><th>Call No.</th><!-- TMPL_UNLESS NAME="itemsloop" --><th>&nbsp;</th><!-- /TMPL_UNLESS -->
+                <th>
+                    <a href="/cgi-bin/koha/opac-shelves.pl" onclick="CheckAll(); return false;"><img src="<!-- TMPL_VAR NAME="themelang" -->/images/checkall.gif" height="18" width="18" alt="Check All" title="Check All" border="0" /></a></th><th>&nbsp;</th><th>Title</th><th>Author</th><th>Call No.
+                </th>
+                <!-- TMPL_UNLESS NAME="itemsloop" -->
+                <th>
+                    &nbsp;
+                </th>
+                <!-- /TMPL_UNLESS -->
         </tr>
         <!-- TMPL_IF NAME="itemsloop" -->
         <!-- TMPL_LOOP Name="itemsloop" -->
@@ -33,8 +40,16 @@
     <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="shelfnumber" value="<!-- TMPL_VAR Name="shelfnumber" -->" /><input type="hidden" name="viewshelf" value="<!-- TMPL_VAR Name="shelfnumber" -->" /><input type="hidden" name="modifyshelfcontents" value="1" /><input type="submit" value="Save" /></td>
+            <td>
+                <label for="addbarcode">Barcode:</label>
+            </td>
+            <td>
+                <input name="addbarcode" type="text" id="addbarcode" size="14" maxlength="14" />
+                <input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR Name="shelfnumber" -->" />
+                <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>

Index: opac/opac-addbookbybiblionumber.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-addbookbybiblionumber.pl,v
retrieving revision 1.5.2.3
retrieving revision 1.5.2.4
diff -u -b -r1.5.2.3 -r1.5.2.4
--- opac/opac-addbookbybiblionumber.pl	7 Dec 2006 15:42:15 -0000	1.5.2.3
+++ opac/opac-addbookbybiblionumber.pl	11 Dec 2006 17:10:06 -0000	1.5.2.4
@@ -2,7 +2,7 @@
 #script to provide bookshelf management
 # WARNING: This file uses 4-character tabs!
 #
-# $Header: /sources/koha/koha/opac/opac-addbookbybiblionumber.pl,v 1.5.2.3 2006/12/07 15:42:15 toins Exp $
+# $Header: /sources/koha/koha/opac/opac-addbookbybiblionumber.pl,v 1.5.2.4 2006/12/11 17:10:06 toins Exp $
 #
 # Copyright 2000-2002 Katipo Communications
 #
@@ -29,15 +29,18 @@
 use C4::Circulation::Circ2;
 use C4::Auth;
 use C4::Interface::CGI::Output;
-use HTML::Template;
 
-my $env;
 my $query        = new CGI;
 my $biblionumber = $query->param('biblionumber');
 my $shelfnumber  = $query->param('shelfnumber');
 my $newbookshelf = $query->param('newbookshelf');
 my $category     = $query->param('category');
 
+warn "biblionumber=".$biblionumber;
+warn "shelfnumber=".$shelfnumber;
+warn "newbookshelf=".$newbookshelf;
+warn "category=".$category;
+
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
     {
         template_name   => "opac-addbookbybiblionumber.tmpl",
@@ -47,19 +50,17 @@
     }
 );
 
-my $x;    # for trash
-( $x, $x, $shelfnumber ) =
-  AddShelf( '', $newbookshelf, $loggedinuser, $category )
-  if $newbookshelf;
+$shelfnumber = AddShelf( '', $newbookshelf, $loggedinuser, $category ) if $newbookshelf;
 
 if ($shelfnumber) {
-    &AddToShelfFromBiblio( $env, $biblionumber, $shelfnumber );
-    print
-"Content-Type: text/html\n\n<html><body onload=\"window.close()\"></body></html>";
+    warn "add shelf from biblio.";
+    &AddToShelfFromBiblio( $biblionumber, $shelfnumber );
+    
+    print $query->header;
+    print "<html><body onload=\"window.close();\"></body></html>";
     exit;
 }
 else {
-
     my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
 
     my ($shelflist) = GetShelves( $loggedinuser, 3 );
@@ -101,6 +102,9 @@
 }
 
 # $Log: opac-addbookbybiblionumber.pl,v $
+# Revision 1.5.2.4  2006/12/11 17:10:06  toins
+# fixing some bugs on bookshelves.
+#
 # Revision 1.5.2.3  2006/12/07 15:42:15  toins
 # synching opac & intranet.
 # fix some broken link & bugs.

Index: opac/opac-shelves.pl
===================================================================
RCS file: /sources/koha/koha/opac/opac-shelves.pl,v
retrieving revision 1.8.2.4
retrieving revision 1.8.2.5
diff -u -b -r1.8.2.4 -r1.8.2.5
--- opac/opac-shelves.pl	7 Dec 2006 15:42:15 -0000	1.8.2.4
+++ opac/opac-shelves.pl	11 Dec 2006 17:10:06 -0000	1.8.2.5
@@ -1,8 +1,5 @@
 #!/usr/bin/perl
-#script to provide bookshelf management
-# WARNING: This file uses 4-character tabs!
-#
-# $Header: /sources/koha/koha/opac/opac-shelves.pl,v 1.8.2.4 2006/12/07 15:42:15 toins Exp $
+
 #
 # Copyright 2000-2002 Katipo Communications
 #
@@ -21,17 +18,61 @@
 # Koha; if not, write to the Free Software Foundation, Inc., 59 Temple Place,
 # Suite 330, Boston, MA  02111-1307 USA
 
+# $Id: opac-shelves.pl,v 1.8.2.5 2006/12/11 17:10:06 toins Exp $
+
+=head1 NAME
+
+    opac-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 C4::Koha;
 use CGI;
 use C4::Output;
 use C4::BookShelves;
 use C4::Circulation::Circ2;
 use C4::Auth;
 use C4::Interface::CGI::Output;
-use HTML::Template;
 
-my $env;
 my $query = new CGI;
 
 my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
@@ -43,12 +84,6 @@
     }
 );
 
-# load the languages
-my @languages_options = displayLanguages($query);
-my $languages_count   = @languages_options;
-if ( $languages_count > 1 ) {
-    $template->param( languages => \@languages_options );
-}
 if ( $query->param('modifyshelfcontents') ) {
     my $shelfnumber = $query->param('shelfnumber');
     my $barcode     = $query->param('addbarcode');
@@ -66,15 +101,17 @@
 my ($shelflist) = GetShelves( $loggedinuser, 2 );
 
 $template->param( { loggedinuser => $loggedinuser, } );
+my $op = $query->param('op');
+
 SWITCH: {
-    if ( $query->param('op') eq 'modifsave' ) {
+    if ( $op && ( $op eq 'modifsave' ) ) {
         ModShelf(
             $query->param('shelfnumber'), $query->param('shelfname'),
             $loggedinuser,                $query->param('category')
         );
         last SWITCH;
     }
-    if ( $query->param('op') eq 'modif' ) {
+    if ( $op && ( $op eq 'modif' ) ) {
         my ( $shelfnumber, $shelfname, $owner, $category ) =
           GetShelf( $query->param('shelf') );
         $template->param(
@@ -97,27 +134,16 @@
     }
 }
 
-# set the default tab, etc.
-my $shelf_type = $query->param('display');
-if ( ( !$shelf_type ) || ( $shelf_type eq 'privateshelves' ) ) {
-    $template->param( showprivateshelves => 1 );
-}
-elsif ( $shelf_type eq 'publicshelves' ) {
-    $template->param( showpublicshelves => 1 );
-}
 ($shelflist) =
   GetShelves( $loggedinuser, 2 )
   ;    # rebuild shelflist in case a shelf has been added
 
 my $color = '';
 my @shelvesloop;
-my @shelveslooppriv;
 foreach my $element ( sort keys %$shelflist ) {
     my %line;
-    my %linepriv;
-    ( $color eq 0 ) ? ( $color = 1 ) : ( $color = 0 );
-    if ( $shelflist->{$element}->{'category'} eq 2 ) {
-        $line{'color'}     = $color;
+    ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+    $line{'toggle'}    = $color;
         $line{'shelf'}     = $element;
         $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
         $line{ "category" . $shelflist->{$element}->{'category'} } = 1;
@@ -131,47 +157,31 @@
           unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
         push( @shelvesloop, \%line );
     }
-    elsif ( $shelflist->{$element}->{'category'} eq 1 ) {
-        $linepriv{'color'}     = $color;
-        $linepriv{'shelf'}     = $element;
-        $linepriv{'shelfname'} = $shelflist->{$element}->{'shelfname'};
-        $linepriv{ "category" . $shelflist->{$element}->{'category'} } = 1;
-        $linepriv{'mine'} = 1
-          if $shelflist->{$element}->{'owner'} eq $loggedinuser;
-        $linepriv{'shelfbookcount'} = $shelflist->{$element}->{'count'};
-        $linepriv{'canmanage'}      =
-          ShelfPossibleAction( $loggedinuser, $element, 'manage' );
-        $linepriv{'firstname'} = $shelflist->{$element}->{'firstname'}
-          unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
-        $linepriv{'surname'} = $shelflist->{$element}->{'surname'}
-          unless $shelflist->{$element}->{'owner'} eq $loggedinuser;
-        push( @shelveslooppriv, \%linepriv );
-    }
-}
 $template->param(
-    shelveslooppriv => \@shelveslooppriv,
-    shelvesloop     => \@shelvesloop
+    shelvesloop             => \@shelvesloop,
+    intranetcolorstylesheet =>
+      C4::Context->preference("intranetcolorstylesheet"),
+    intranetstylesheet => C4::Context->preference("intranetstylesheet"),
+    IntranetNav        => C4::Context->preference("IntranetNav"),
 );
 
 output_html_with_http_headers $query, $cookie, $template->output;
 
-# sub editshelf {
-#     my ($shelfnumber) = @_;
-#     my ($shelfnumber,$shelfname,$owner,$category) = GetShelf($shelfnumber);
-#     $template->param(edit => 1,
-#                     shelfnumber => $shelfnumber,
-#                     shelfname => $shelfname,
-#                     "category$category" => 1);
-# }
 sub shelves {
     if ( my $newshelf = $query->param('addshelf') ) {
-        my ( $status, $string ) = AddShelf(
+        my  $shelfnumber = AddShelf(
             $newshelf,
             $query->param('owner'),
             $query->param('category')
         );
-        if ($status) {
-            $template->param( status1 => $status, string1 => $string );
+
+        if ( $shelfnumber == -1 ) {    #shelf already exists.
+            $template->param(
+                {
+                    shelfnumber => $shelfnumber,
+                    already     => 1
+                }
+            );
         }
     }
     my @paramsloop;
@@ -179,10 +189,10 @@
         my %line;
         if (/DEL-(\d+)/) {
             my $delshelf = $1;
-            my ( $status, $string ) = DelShelf($delshelf);
+            my ( $status, $count ) = DelShelf($delshelf);
             if ($status) {
                 $line{'status'} = $status;
-                $line{'string'} = $string;
+                $line{'count'}  = $count;
             }
         }
 
@@ -195,8 +205,8 @@
     my @shelvesloop;
     foreach my $element ( sort keys %$shelflist ) {
         my %line;
-        ( $color eq 0 ) ? ( $color = 1 ) : ( $color = 0 );
-        $line{'color'}          = $color;
+        ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+        $line{'toggle'}         = $color;
         $line{'shelf'}          = $element;
         $line{'shelfname'}      = $shelflist->{$element}->{'shelfname'};
         $line{'shelfbookcount'} = $shelflist->{$element}->{'count'};
@@ -219,28 +229,9 @@
     my $color      = '';
     my @itemsloop;
     foreach $item ( sort { $a->{'barcode'} cmp $b->{'barcode'} } @$itemlist ) {
-        my %line;
-        if ( $item->{'itemnumber'} ) {
-            ( $color eq 0 ) ? ( $color = 1 ) : ( $color = 0 );
-            $line{'color'}           = $color;
-            $line{'itemnumber'}      = $item->{'itemnumber'};
-            $line{'barcode'}         = $item->{'barcode'};
-            $line{'title'}           = $item->{'title'};
-            $line{'isbn'}            = $item->{'isbn'};
-            $line{'subtitle'}        = $item->{'subtitle'};
-            $line{'author'}          = $item->{'author'};
-            $line{'publicationyear'} = $item->{'publicationyear'};
-            $line{'publishercode'}   = $item->{'publishercode'};
-            $line{'place'}           = $item->{'place'};
-            $line{'pages'}           = $item->{'pages'};
-            $line{'notes'}           = $item->{'notes'};
-            $line{'size'}            = $item->{'size'};
-            $line{'classification'}  = $item->{'classification'};
-            $line{'itemtype'}        = $item->{'itemtype'};
-            $line{'ccode'}           = $item->{'ccode'};
-            $line{biblionumber}      = $item->{biblionumber};
-            push( @itemsloop, \%line );
-        }
+        ( $color eq 1 ) ? ( $color = 0 ) : ( $color = 1 );
+        $item->{'toggle'} = $color;
+        push( @itemsloop, $item );
     }
     $template->param(
         itemsloop   => \@itemsloop,
@@ -254,6 +245,9 @@
 
 #
 # $Log: opac-shelves.pl,v $
+# Revision 1.8.2.5  2006/12/11 17:10:06  toins
+# fixing some bugs on bookshelves.
+#
 # Revision 1.8.2.4  2006/12/07 15:42:15  toins
 # synching opac & intranet.
 # fix some broken link & bugs.
@@ -271,99 +265,3 @@
 # Revision 1.8  2006/05/21 02:30:17  kados
 # syncing dev-week and HEAD
 #
-# Revision 1.7  2005/05/04 09:02:38  tipaul
-# synch'ing 2.2 and head
-#
-# Revision 1.3.2.4  2005/03/25 17:04:28  tipaul
-# adding virtual shelves & suggestions button to the top
-#
-# Revision 1.3.2.3  2005/01/27 17:18:28  oleonard
-# Taking table cell background color information out of the script and moving it into the template (requires update to opac-shelves.tmpl)
-#
-# Revision 1.3.2.2  2005/01/11 20:18:29  oleonard
-# Adding call number and item type to list of returned variables
-#
-# Revision 1.3.2.1  2005/01/11 16:33:57  tipaul
-# fix for http://bugs.koha.org/cgi-bin/bugzilla/show_bug.cgi?id=811 :
-# The OPAC requires uses to log in to view virtual shelves, and it requires a user
-# with librarian privileges.  Virtual shelves should be viewable by all users,
-# logged in or not, and editable by all logged-in users in good standing.
-#
-# Revision 1.3  2005/01/03 11:09:34  tipaul
-# synch'ing virtual shelves management in opac with the librarian one, that has more features
-#
-# Revision 1.5  2004/12/16 11:30:57  tipaul
-# adding bookshelf features :
-# * create bookshelf on the fly
-# * modify a bookshelf name & status
-#
-# Revision 1.4  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)
-#
-# Revision 1.3  2004/12/02 16:38:50  tipaul
-# improvement in book shelves
-#
-# Revision 1.2  2004/11/19 16:31:30  tipaul
-# bugfix for bookshelves not in official CVS
-#
-# Revision 1.1.2.1  2004/03/10 15:08:18  tipaul
-# modifying shelves : introducing category of shelf : private, public, free for all
-#
-# Revision 1.13  2004/02/11 08:35:31  tipaul
-# synch'ing 2.0.0 branch and head
-#
-# Revision 1.12.2.1  2004/02/06 14:22:19  tipaul
-# fixing bugs in bookshelves management.
-#
-# Revision 1.12  2003/02/05 10:04:14  acli
-# Worked around weirdness with HTML::Template; without the {}, it complains
-# of being passed an odd number of arguments even though we are not
-#
-# Revision 1.11  2003/02/05 09:23:03  acli
-# Fixed a few minor errors to make it run
-# Noted correct tab size
-#
-# Revision 1.10  2003/02/02 07:18:37  acli
-# Moved C4/Charset.pm to C4/Interface/CGI/Output.pm
-#
-# Create output_html_with_http_headers function to contain the "print $query
-# ->header(-type => guesstype...),..." call. This is in preparation for
-# non-HTML output (e.g., text/xml) and charset conversion before output in
-# the future.
-#
-# Created C4/Interface/CGI/Template.pm to hold convenience functions specific
-# to the CGI interface using HTML::Template
-#
-# Modified moremembers.pl to make the "sex" field localizable for languages
-# where M and F doesn't make sense
-#
-# Revision 1.9  2002/12/19 18:55:40  hdl
-# Templating reservereport et shelves.
-#
-# Revision 1.9  2002/08/14 18:12:51  hdl
-# Templating files
-#
-# Revision 1.8  2002/08/14 18:12:51  tonnesen
-# Added copyright statement to all .pl and .pm files
-#
-# Revision 1.7  2002/07/05 05:03:37  tonnesen
-# Minor changes to authentication routines.
-#
-# Revision 1.5  2002/07/04 19:42:48  tonnesen
-# Minor changes
-#
-# Revision 1.4  2002/07/04 19:21:29  tonnesen
-# Beginning of authentication api.  Applied to shelves.pl for now as a test case.
-#
-# Revision 1.2.2.1  2002/06/26 20:28:15  tonnesen
-# Some udpates that I made here locally a while ago.  Still won't be useful, but
-# should be functional
-#
-#
-#
-
-# Local Variables:
-# tab-width: 4
-# End:





More information about the Koha-cvs mailing list