Merged in updates from rel-1-2
authortonnesen <tonnesen>
Tue, 2 Jul 2002 17:48:06 +0000 (17:48 +0000)
committertonnesen <tonnesen>
Tue, 2 Jul 2002 17:48:06 +0000 (17:48 +0000)
C4/BookShelves.pm
shelves.pl

index e47a8ab..d2c5d7c 100755 (executable)
@@ -3,9 +3,6 @@ package C4::BookShelves; #asummes C4/BookShelves
 #
 # $Header$
 #
-#
-# Change log is at the bottom of the file
-#
 #requires DBI.pm to be installed
 
 use strict;
@@ -20,12 +17,6 @@ $VERSION = 0.01;
     
 @ISA = qw(Exporter);
 @EXPORT = qw(&GetShelfList &GetShelfContents &AddToShelf &RemoveFromShelf &AddShelf &RemoveShelf);
-
-sub AddShelf {
-}
-
-sub RemoveShelf {
-}
 %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
                  
 # your exported package globals go here,
@@ -114,11 +105,11 @@ sub AddShelf {
     my $sth=$dbh->prepare("select * from bookshelf where shelfname=$q_shelfname");
     $sth->execute;
     if ($sth->rows) {
-       return(0, "Shelf \"$shelfname\" already exists");
+       return(1, "Shelf \"$shelfname\" already exists");
     } else {
        $sth=$dbh->prepare("insert into bookshelf (shelfname) values ($q_shelfname)");
        $sth->execute;
-       return (1, "Done");
+       return (0, "Done");
     }
 }
 
@@ -128,11 +119,11 @@ sub RemoveShelf {
     $sth->execute;
     my ($count)=$sth->fetchrow;
     if ($count) {
-       return (0, "Shelf has $count items on it");
+       return (1, "Shelf has $count items on it.  Please remove all items before deleting this shelf.");
     } else {
        $sth=$dbh->prepare("delete from bookshelf where shelfnumber=$shelfnumber");
        $sth->execute;
-       return (1, "Done");
+       return (0, "Done");
     }
 }
 
@@ -142,10 +133,10 @@ END { }       # module clean-up code here (global destructor)
 
 #
 # $Log$
-# Revision 1.2  2001/02/07 23:47:43  tonnesen
-# Added header and log substition variables
+# Revision 1.3  2002/07/02 17:48:06  tonnesen
+# Merged in updates from rel-1-2
 #
-# Revision 1.1  2001/02/07 20:27:17  tonnesen
-# Start of code to implement virtual bookshelves in Koha.
+# Revision 1.2.2.1  2002/06/26 20:46:48  tonnesen
+# Inserting some changes I made locally a while ago.
 #
 #
index 094e689..b09613b 100755 (executable)
@@ -3,8 +3,6 @@
 #
 # $Header$
 #
-# Change log is at the bottom of the file
-#
 
 use strict;
 use C4::Search;
@@ -45,6 +43,7 @@ if ($query->param('modifyshelfcontents')) {
 
 SWITCH: {
     if ($query->param('viewshelf')) {  viewshelf($query->param('viewshelf')); last SWITCH;}
+    if ($query->param('shelves')) {  shelves(); last SWITCH;}
     print << "EOF";
     <center>
     <table border=0 cellpadding=4 cellspacing=0>
@@ -62,9 +61,60 @@ EOF
        print "<tr><td bgcolor=$color><a href=shelves.pl?viewshelf=$_>$shelflist->{$_}->{'shelfname'} ($shelflist->{$_}->{'count'} books)</a></td></tr>\n";
     }
     print "</table>\n";
+    print "<P><a href=shelves.pl?shelves=1>Add or Remove Book Shelves</a>\n";
+}
+
+
+
+sub shelves {
+    if (my $newshelf=$query->param('addshelf')) {
+       my ($status, $string) = AddShelf($env,$newshelf);
+       if ($status) {
+           print "<font color=red>$string</font><p>\n";
+       }
+    }
+    foreach ($query->param()) {
+       if (/DEL-(\d+)/) {
+           my $delshelf=$1;
+           my ($status, $string) = RemoveShelf($env,$delshelf);
+           if ($status) {
+               print "<font color=red>$string</font><p>\n";
+           }
+       }
+    }
+    my ($shelflist) = GetShelfList();
+    print << "EOF";
+<center>
+<a href=shelves.pl>Modify Shelf Contents</a><p>
+<h1>Bookshelves</h1>
+<table border=0 cellpadding=7>
+<tr><td align=center>
+<form method=post>
+<input type=hidden name=shelves value=1>
+<table border=0 cellpadding=0 cellspacing=0>
+<tr><th bgcolor=$headerbackgroundcolor>
+<font color=white>Select Shelves to Delete</font>
+</th></tr>
+EOF
+    my $color='';
+    my $color='';
+    foreach (sort keys %$shelflist) {
+       ($color eq $linecolor1) ? ($color=$linecolor2) : ($color=$linecolor1);
+       print "<tr><td bgcolor=$color><input type=checkbox name=DEL-$_> $shelflist->{$_}->{'shelfname'} ($shelflist->{$_}->{'count'} books)</td></tr>\n";
+    }
+    print "</table>\n";
+    print '<p><input type=submit value="Delete Shelves"><p>';
+    print "</td><td align=center valign=top>\n";
+    print "<form method=post>\n";
+    print "<input type=hidden name=shelves value=1>\n";
+    print "<p>Add Shelf: <input name=addshelf size=25><p>\n";
+    print '<p><input type=submit value="Add New Shelf"><p>';
+    print "</form>\n";
+    print "</td></tr></table>\n";
 }
 
 
+
 sub viewshelf {
     my $shelfnumber=shift;
     my ($itemlist) = GetShelfContents($env, $shelfnumber);
@@ -116,14 +166,17 @@ EOF
 
 #
 # $Log$
-# Revision 1.2  2001/02/07 23:47:43  tonnesen
-# Added header and log substition variables
+# Revision 1.3  2002/07/02 17:48:06  tonnesen
+# Merged in updates from rel-1-2
 #
-# Revision 1.1  2001/02/07 20:27:16  tonnesen
-# Start of code to implement virtual bookshelves in Koha.
+# 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
 #
 #
 #
 
 
 
+print endpage();
+print endmenu('catalogue');