Browse Source

adding bookshelf features :

* create bookshelf on the fly
* modify a bookshelf name & status
3.0.x
tipaul 18 years ago
parent
commit
f72a2ceb5f
  1. 31
      C4/BookShelves.pm
  2. 48
      bookshelves/shelves.pl
  3. 19
      koha-tmpl/intranet-tmpl/default/en/bookshelves/shelves.tmpl

31
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

48
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

19
koha-tmpl/intranet-tmpl/default/en/bookshelves/shelves.tmpl

@ -109,6 +109,7 @@
<table class="small">
<tr>
<th class="catalogue">Shelf name</th>
<th class="catalogue">Category</th>
<th class="catalogue">Content size</th>
<th class="catalogue">Modify</th>
</tr>
@ -119,11 +120,25 @@
<!-- TMPL_VAR NAME="shelfname" -->
</a>
</td>
<td bgcolor="<!-- TMPL_VAR NAME="color" -->">
<!-- TMPL_IF NAME="category1" -->
Private
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="category2" -->
Public
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="category3" -->
Free
<!-- /TMPL_IF -->
</td>
<td bgcolor="<!-- TMPL_VAR NAME="color" -->">
<!-- TMPL_VAR NAME="shelfbookcount" --> item(s)
</td>
<!-- TMPL_IF name="mine" -->
<td bgcolor="<!-- TMPL_VAR NAME="color" -->"><a href="shelves.pl?op=modif&shelf=<!-- TMPL_VAR NAME="shelf" -->" class="button catalogue">Modify</a></td>
<td bgcolor="<!-- TMPL_VAR NAME="color" -->">
<a href="shelves.pl?op=modif&shelf=<!-- TMPL_VAR NAME="shelf" -->" class="button catalogue">Modify</a>
<!-- TMPL_VAR name="surname" --><!-- TMPL_VAR name="firstname" -->
</td>
<!-- /TMPL_IF -->
</tr>
<!-- /TMPL_LOOP -->
@ -141,7 +156,7 @@
<input type="hidden" name="op" value="modifsave">
<h2 class="catalogue">Modify shelf</h2>
<input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR name="shelfnumber" -->">
<p><label>Name</label><input type="text" name="addshelf" size="25" value="<!-- TMPL_VAR name="shelfname"-->"></p>
<p><label>Name</label><input type="text" name="shelfname" size="25" value="<!-- TMPL_VAR name="shelfname"-->"></p>
<p><label>Owner</label><input type="hidden" name="owner" value="<!-- TMPL_VAR NAME="loggedinuser" -->"><!-- TMPL_VAR NAME="loggedinusername" --></p>
<p><label>Category</label>
<select name="category">

Loading…
Cancel
Save