From f72a2ceb5fc6ac1577283990901be4c724fa7694 Mon Sep 17 00:00:00 2001 From: tipaul Date: Thu, 16 Dec 2004 11:30:57 +0000 Subject: [PATCH] adding bookshelf features : * create bookshelf on the fly * modify a bookshelf name & status --- C4/BookShelves.pm | 31 ++++++++---- bookshelves/shelves.pl | 48 ++++++++++++++----- .../default/en/bookshelves/shelves.tmpl | 19 +++++++- 3 files changed, 75 insertions(+), 23 deletions(-) diff --git a/C4/BookShelves.pm b/C4/BookShelves.pm index ea92992e34..381dacbab2 100755 --- a/C4/BookShelves.pm +++ b/C4/BookShelves.pm @@ -53,10 +53,11 @@ items to and from bookshelves. =cut @ISA = qw(Exporter); -@EXPORT = qw(&GetShelfList &GetShelfContents &GetShelf - &AddToShelf &AddToShelfFromBiblio - &RemoveFromShelf &AddShelf &RemoveShelf - &ShelfPossibleAction); +@EXPORT = qw(&GetShelfList &GetShelfContents &GetShelf + &AddToShelf &AddToShelfFromBiblio + &RemoveFromShelf &AddShelf &ModifShelf + &RemoveShelf &ShelfPossibleAction + ); my $dbh = C4::Context->dbh; @@ -115,7 +116,7 @@ sub GetShelfList { my ($owner,$mincategory) = @_; # 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 - my $sth=$dbh->prepare("SELECT bookshelf.shelfnumber, bookshelf.shelfname,owner,surname,firstname, + my $sth=$dbh->prepare("SELECT bookshelf.shelfnumber, bookshelf.shelfname,owner,surname,firstname,category, count(shelfcontents.itemnumber) as count FROM bookshelf LEFT JOIN shelfcontents @@ -125,9 +126,10 @@ sub GetShelfList { GROUP BY bookshelf.shelfnumber order by shelfname"); $sth->execute($owner,$mincategory); my %shelflist; - while (my ($shelfnumber, $shelfname,$owner,$surname,$firstname,$count) = $sth->fetchrow) { + 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; @@ -238,11 +240,9 @@ success, or an error message giving the reason for failure. C<$env> is ignored. =cut -#' -# FIXME - Perhaps this could/should return the number of the new bookshelf -# as well? + sub AddShelf { - my ($env, $shelfname,$owner,$category) = @_; + my ($env, $shelfname, $owner, $category) = @_; my $sth=$dbh->prepare("select * from bookshelf where shelfname=?"); $sth->execute($shelfname); if ($sth->rows) { @@ -255,6 +255,12 @@ sub AddShelf { } } +sub ModifShelf { + my ($shelfnumber, $shelfname, $owner, $category) = @_; + my $sth = $dbh->prepare("update bookshelf set shelfname=?,owner=?,category=? where shelfnumber=?"); + $sth->execute($shelfname,$owner,$category,$shelfnumber); +} + =item RemoveShelf ($status, $msg) = &RemoveShelf($env, $shelfnumber); @@ -290,6 +296,11 @@ END { } # module clean-up code here (global destructor) # # $Log$ +# 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 diff --git a/bookshelves/shelves.pl b/bookshelves/shelves.pl index 48f66448c7..3ab48a3689 100755 --- a/bookshelves/shelves.pl +++ b/bookshelves/shelves.pl @@ -66,9 +66,27 @@ $template->param({ loggedinuser => $loggedinuser, headerbackgroundcolor => $headerbackgroundcolor, circbackgroundcolor => $circbackgroundcolor }); SWITCH: { - if ($query->param('op') eq 'modif') { editshelf($query->param('shelf')); last SWITCH;} - if ($query->param('viewshelf')) { viewshelf($query->param('viewshelf')); last SWITCH;} - if ($query->param('shelves')) { shelves(); last SWITCH;} + if ($query->param('op') eq 'modifsave') { + ModifShelf($query->param('shelfnumber'),$query->param('shelfname'),$loggedinuser,$query->param('category')); + last SWITCH; + } + if ($query->param('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')) { + viewshelf($query->param('viewshelf')); + last SWITCH; + } + if ($query->param('shelves')) { + shelves(); + last SWITCH; + } } ($shelflist) = GetShelfList($loggedinuser,2); # rebuild shelflist in case a shelf has been added @@ -81,9 +99,12 @@ foreach my $element (sort keys %$shelflist) { $line{'color'}= $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); } @@ -91,14 +112,14 @@ $template->param(shelvesloop => \@shelvesloop); output_html_with_http_headers $query, $cookie, $template->output; -sub editshelf { - my ($shelfnumber) = @_; - my ($shelfnumber,$shelfname,$owner,$category) = GetShelf($shelfnumber); - warn "($shelfnumber,$shelfname,$owner,$category)"; - $template->param(edit => 1, - shelfname => $shelfname, - "category$category" => 1); -} +# 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($env,$newshelf,$query->param('owner'),$query->param('category')); @@ -167,6 +188,11 @@ sub viewshelf { # # $Log$ +# 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 diff --git a/koha-tmpl/intranet-tmpl/default/en/bookshelves/shelves.tmpl b/koha-tmpl/intranet-tmpl/default/en/bookshelves/shelves.tmpl index dc0e48f5b0..42cfc11fed 100644 --- a/koha-tmpl/intranet-tmpl/default/en/bookshelves/shelves.tmpl +++ b/koha-tmpl/intranet-tmpl/default/en/bookshelves/shelves.tmpl @@ -109,6 +109,7 @@ + @@ -119,11 +120,25 @@ + - + @@ -141,7 +156,7 @@

Modify shelf

"> -

">

+

">

">

Shelf nameCategory Content size Modify
"> + + Private + + + Public + + + Free + + "> item(s) ">" class="button catalogue">Modify"> + " class="button catalogue">Modify + +