<!-- TMPL_INCLUDE NAME="masthead.inc" -->
<div id="doc3" class="yui-t1">
- <div id="bd">
- <div id="yui-main">
- <div class="yui-b"><div class="yui-g">
-
+ <div id="bd">
+ <div id="yui-main">
+ <div class="yui-b">
+ <div class="yui-g">
<!-- TMPL_IF NAME="viewshelf" -->
<h3><a href="/cgi-bin/koha/opac-shelves.pl">Lists</a> <img src="<!-- TMPL_VAR NAME="themelang" -->/../images/caret.gif" width="16" height="16" alt=">" border="0" /> <em><!-- TMPL_VAR NAME="shelfname" --></em></h3>
<th>Title</th>
<th>Author</th>
<th>Copyright</th>
- <th>Call No.</th>
</tr>
<!-- TMPL_LOOP NAME="itemsloop" -->
<!-- TMPL_IF NAME="toggle" -->
</td>
<td><!-- TMPL_VAR NAME="author" --></td>
<td><!-- TMPL_VAR NAME="copyrightdate" --></td>
- <td><!-- TMPL_VAR NAME="classification" --></td>
</tr>
<!-- /TMPL_LOOP --><!-- /itemsloop -->
</table>
<!-- TMPL_ELSE -->
- <div class="message">This List is empty.</div>
+ <div class="message">This List is empty. You can add to your lists from the results of any <a href="opac-main.pl">search</a>!</div>
<!-- /TMPL_IF --><!-- /itemsloop -->
<!-- /TMPL_IF --><!-- /viewshelf -->
<!-- TMPL_IF NAME="manageshelf" -->
+ <form method="post" action="/cgi-bin/koha/opac-shelves.pl">
<!-- TMPL_IF NAME="itemsloop" -->
- <input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR NAME="shelfnumber" -->" />
- <input type="hidden" name="modifyshelfcontents" value="1" />
- <input type="hidden" name="viewshelf" value="<!-- TMPL_VAR NAME="shelfnumber" -->" /><input type="submit" value="Remove Selected Items" class="icon delete" onclick="return confirmDelete('Are you sure you want to remove these items from the list?')" />
+ <input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR NAME="shelfnumber" -->" />
+ <input type="hidden" name="modifyshelfcontents" value="1" />
+ <input type="hidden" name="viewshelf" value="<!-- TMPL_VAR NAME="shelfnumber" -->" /><input type="submit" value="Remove Selected Items" class="icon delete" onclick="return confirmDelete('Are you sure you want to remove these items from the list?')" />
+ <!-- TMPL_ELSE -->
+ <input type="hidden" name="DEL-<!-- TMPL_VAR NAME="shelfnumber" -->" value="1" />
+ <input type="hidden" name="shelves" value="1" />
+ <input type="submit" class="icon delete" value="Delete this List" onclick="return confirmDelete('Are you sure you want to delete this List?')" />
<!-- /TMPL_IF -->
- <!-- /TMPL_IF -->
- </form>
-
- <!-- TMPL_IF NAME="manageshelf" -->
- <!-- TMPL_UNLESS NAME="itemsloop" --><form method="get" action="/cgi-bin/koha/opac-shelves.pl"><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 List" onclick="return confirmDelete('Are you sure you want to delete this List?')" /></form><!-- /TMPL_UNLESS -->
+ </form>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="shelves" -->
<p class="error"><!-- TMPL_VAR NAME="string" --></p>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
- <form method="post" action="/cgi-bin/koha/opac-shelves.pl">
- <input type="hidden" name="shelves" value="1">
- <div class="form">
- <table>
- <caption>Create a New List</caption>
- <tr><th><label for="addshelf">List Name:</label> </th><td> <input id="addshelf" type="text" name="addshelf" size="60"><input type="hidden" name="owner" id="owner" value="<!-- TMPL_VAR NAME="loggedinuser" -->"></td></tr>
- </table></div>
- <p><input type="hidden" name="category" value="1" /><input type="submit" value="Add New Shelf" class="icon add"></p>
- </form>
<!-- /TMPL_IF --><!-- /shelves -->
+ <!-- TMPL_IF NAME="already" -->
+ <p class="error">Error: A shelf named <!-- TMPL_VAR NAME="already" --> already exists. Please pick a different name.</p>
+ <!-- /TMPL_IF -->
+
<!-- TMPL_IF NAME="edit" -->
- <form method="post">
+ <form method="post" action="/cgi-bin/koha/opac-shelves.pl">
<input type="hidden" name="op" value="modifsave">
<input type="hidden" name="shelfnumber" value="<!-- TMPL_VAR NAME="shelfnumber" -->">
<div class="form">
<table>
- <caption>Edit List <em><!-- TMPL_VAR NAME="shelfname"--></em></caption>
+ <caption>Edit List <em><!-- TMPL_VAR NAME="shelfname" --></em></caption>
<tr><th><label for="shelfname">List Name: </label></th><td><input type="text" id="shelfname" name="shelfname" size="60" value="<!-- TMPL_VAR NAME="shelfname"-->" /></td></tr>
<tr><th><label for="sortfield" >Select sort field for this List: </label></th>
<td><select name="sortfield">
<!-- TMPL_IF NAME="showprivateshelves" -->
<li id="privateshelves_tab" class="on"><a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">Your Lists</a></li>
<!-- TMPL_ELSE -->
- <li id="privateshelves_tab" class="off"><a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">Your Lists</a> </li>
+ <li id="privateshelves_tab" class="off"><a href="/cgi-bin/koha/opac-shelves.pl?display=privateshelves">Your Lists</a></li>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="showpublicshelves" -->
<li id="publicshelves_tab" class="on"><a href="/cgi-bin/koha/opac-shelves.pl?display=publicshelves">Public Lists</a></li>
<li id="publicshelves_tab" class="off"><a href="/cgi-bin/koha/opac-shelves.pl?display=publicshelves">Public Lists</a></li>
<!-- /TMPL_IF -->
</ul>
- <!-- TMPL_IF NAME="showprivateshelves" --><div id="privateshelves" class="tab-container" style="display:block;"><!-- TMPL_ELSE --><div id="privateshelves" class="tab-container" style="display:none;"><!-- /TMPL_IF -->
- <!-- TMPL_IF NAME="loggedinusername" -->
- <!-- TMPL_IF NAME="shelveslooppriv" -->
+ <!-- TMPL_IF NAME="showprivateshelves" -->
+ <div id="privateshelves" class="tab-container" style="display:block;">
+ <!-- TMPL_ELSE -->
+ <div id="privateshelves" class="tab-container" style="display:none;">
+ <!-- /TMPL_IF -->
+
+ <!-- TMPL_IF NAME="loggedinusername" -->
<table>
<tr><th>List Name</th><th>Contents</th><th>Sort by</th><th> </th></tr>
+ <!-- TMPL_IF NAME="shelveslooppriv" -->
<!-- TMPL_LOOP NAME="shelveslooppriv" -->
<!-- TMPL_IF NAME="toggle" --><tr class="highlight"><!--TMPL_ELSE--><tr><!-- /TMPL_IF -->
<td><a href="opac-shelves.pl?viewshelf=<!-- TMPL_VAR NAME="shelf" -->"><!-- TMPL_VAR NAME="shelfname" --></a></td>
<!-- TMPL_IF NAME="mine" --><a href="opac-shelves.pl?op=modif&shelf=<!-- TMPL_VAR NAME="shelf" -->">Edit</a> <a class="delete" href="opac-shelves.pl?shelves=1&DEL-<!-- TMPL_VAR NAME="shelf" -->=1">Delete</a><!-- TMPL_ELSE --> <!-- /TMPL_IF --></td></tr>
<!-- /TMPL_LOOP -->
<!-- TMPL_ELSE -->
- <tr><td colspan="4">No Private Lists. Click below to create a new List!</td></tr>
+ <tr><td colspan="4">No Private Lists.</td></tr>
<!-- /TMPL_IF --><!-- /shelveslooppriv -->
</table>
<!-- TMPL_ELSE --><!-- /loggedinusername -->
- <div><a href="/cgi-bin/koha/opac-user.pl">Log in</a> to create your Private Lists</div>
+ <div><a href="/cgi-bin/koha/opac-user.pl">Log in</a> to create new Lists.</div>
<!-- /TMPL_IF --><!-- /loggedinusername -->
- </div>
+ </div><!-- /privateshelves -->
- <!-- TMPL_IF NAME="showpublicshelves" --><div id="publicshelves" class="tab-container" style="display:block;"><!-- TMPL_ELSE --><div id="publicshelves" class="tab-container" style="display:none;"><!-- /TMPL_IF -->
+ <!-- TMPL_IF NAME="showpublicshelves" -->
+ <div id="publicshelves" class="tab-container" style="display:block;">
+ <!-- TMPL_ELSE -->
+ <div id="publicshelves" class="tab-container" style="display:none;">
+ <!-- /TMPL_IF -->
<!-- TMPL_IF NAME="shelvesloop" -->
<table>
<tr><th>List Name</th><th>Contents</th></tr>
<!-- /TMPL_LOOP -->
</table>
<!-- TMPL_ELSE -->
- <!-- TMPL_IF NAME="showpublicshelves" -->No Public Lists.<!-- /TMPL_IF -->
- </div>
+ <!-- TMPL_IF NAME="showpublicshelves" -->No Public Lists.<!-- /TMPL_IF -->
<!-- /TMPL_IF --><!-- /shelvesloop -->
- <!-- /TMPL_UNLESS -->
-</div>
-</div>
-</div>
-<div class="yui-b">
-<!--TMPL_INCLUDE NAME="navigation.inc" -->
+ </div><!-- /publicshelves -->
+ <!-- /TMPL_UNLESS --><!-- /viewshelf -->
+
+ <!-- TMPL_IF NAME="showadd" -->
+ <div style="padding: 1.5em 0em;"><hr /></div>
+ <form method="post" action="/cgi-bin/koha/opac-shelves.pl">
+ <input type="hidden" name="shelves" value="1" />
+ <div class="form">
+ <table>
+ <caption>Create a New List</caption>
+ <tr><th><label for="addshelf">List Name:</label> </th><td>
+ <!-- TMPL_IF NAME="already" -->
+ <input id="addshelf" type="text" name="addshelf" value="<!-- TMPL_VAR NAME="already" -->" size="60" />
+ <!-- TMPL_ELSE -->
+ <input id="addshelf" type="text" name="addshelf" size="60" />
+ <!-- /TMPL_IF -->
+ <input type="hidden" name="owner" id="owner" value="<!-- TMPL_VAR NAME="loggedinuser" -->" />
+ </td></tr>
+ </table>
+ </div>
+ <p><input type="hidden" name="category" value="1" /><input type="submit" value="Add New Shelf" class="icon add" /></p>
+ </form>
+ <!-- /TMPL_IF --><!-- /showadd -->
+ </div>
+ </div>
+ </div>
+ <div class="yui-b">
+<!-- TMPL_INCLUDE NAME="navigation.inc" -->
<!-- TMPL_INCLUDE NAME="usermenu.inc" -->
-</div>
-</div>
+ </div>
+ </div>
+<!-- </div> -->
<!-- TMPL_INCLUDE NAME="opac-bottom.inc" -->
=item C<modifyshelfcontents>
- if this script has to modify the shelve content.
+ if this script has to modify the shelf content.
=item C<shelfnumber>
- to know on which shelve this script has to work.
+ to know on which shelf 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.
+ op can equal the following values:
+ * 'modifsave' to save changes on the shelves
+ * 'modif' to change the template to allow modification of the shelves.
=item C<viewshelf>
- to load the template with 'viewshelves param' which allow to read the shelves information.
+ to load the template with 'viewshelves param' which allows reading the shelves information.
=item C<shelves>
- if equals to 1. then call the function shelves which add
- or delete a shelf.
+ if == 1, then call the function shelves to 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.
+ if the param shelves == 1, then addshelf must be equals to the name of the shelf to add.
=back
use C4::Output;
use C4::Biblio;
+use vars qw($debug);
+
+BEGIN {
+ $debug = $ENV{DEBUG} || 0;
+}
+
my $query = new CGI;
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
if ( ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ) ) {
AddToShelf( $biblio->{'biblionumber'}, $shelfnumber );
foreach ( $query->param ) {
- if (/REM-(\d*)/) {
- my $biblionumber = $1;
- DelFromShelf( $biblionumber, $shelfnumber );
- }
+ /REM-(\d+)/ or next;
+ DelFromShelf( $1, $shelfnumber ); # $1 is biblionumber
}
}
}
+my $showadd = 1;
# set the default tab, etc.
my $shelf_type = $query->param('display');
-if ((!$shelf_type) || ($shelf_type eq 'privateshelves')) {
+if (defined $shelf_type) {
+ if ($shelf_type eq 'privateshelves') {
+ $template->param(showprivateshelves => 1);
+ } elsif ($shelf_type eq 'publicshelves') {
+ $template->param(showpublicshelves => 1);
+ $showadd = 0;
+ } else {
+ $debug and warn "Invalid 'display' param ($shelf_type)";
+ }
+} else {
$template->param(showprivateshelves => 1);
-} elsif ($shelf_type eq 'publicshelves') {
- $template->param(showpublicshelves => 1);
}
# getting the Shelves list
my $op = $query->param('op');
SWITCH: {
- if ( $op && ( $op eq 'modifsave' ) ) {
- ModShelf(
- $query->param('shelfnumber'), $query->param('shelfname'),
- $loggedinuser, $query->param('category'), $query->param('sortfield')
- );
- last SWITCH;
- }
- if ( $op && ( $op eq 'modif' ) ) {
- my ( $shelfnumber, $shelfname, $owner, $category, $sortfield ) =
- GetShelf( $query->param('shelf') );
- $template->param(
- edit => 1,
- shelfnumber => $shelfnumber,
- shelfname => $shelfname,
- "category$category" => 1,
- "sort_$sortfield" => 1,
- );
- last SWITCH;
- }
- if ( $query->param('viewshelf') ) {
-
+ if ( $op ) {
+ if ( $op eq 'modifsave' ) {
+ ModShelf(
+ $query->param('shelfnumber'), $query->param('shelfname'),
+ $loggedinuser, $query->param('category'), $query->param('sortfield')
+ );
+ $shelflist = GetShelves( $loggedinuser, 2 ); # refresh after mods
+ } elsif ( $op eq 'modif' ) {
+ my ( $shelfnumber, $shelfname, $owner, $category, $sortfield ) =GetShelf( $query->param('shelf') );
+ $template->param(
+ edit => 1,
+ shelfnumber => $shelfnumber,
+ shelfname => $shelfname,
+ "category$category" => 1,
+ "sort_$sortfield" => 1,
+ );
+ }
+ 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);
+ $showadd = 1;
$template->param(
shelfname => $shelflist->{$shelfnumber}->{'shelfname'},
shelfnumber => $shelfnumber,
manageshelf => &ShelfPossibleAction( $loggedinuser, $shelfnumber, 'manage' ),
itemsloop => $items,
);
- }
+ } # else {;} # FIXME - some kind of warning *may* be in order
last SWITCH;
}
if ( $query->param('shelves') ) {
);
if ( $shelfnumber == -1 ) { #shelf already exists.
+ $showadd = 1;
$template->param(
- {
shelfnumber => $shelfnumber,
- already => 1
- }
+ already => $newshelf,
);
- }
- print $query->redirect("/cgi-bin/koha/opac-shelves.pl?viewshelf=$shelfnumber");
- exit;
+ } else {
+ print $query->redirect("/cgi-bin/koha/opac-shelves.pl?viewshelf=$shelfnumber");
+ exit; # can't redirect AND expect %line to DO anything!
+ }
}
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;
- }
- print $query->redirect("/cgi-bin/koha/opac-shelves.pl");
- exit;
- }
-
- #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{'shelfvirtualcount'} = $shelflist->{$element}->{'count'};
- push( @shelvesloop, \%line );
+ /^DEL-(\d+)/ or next;
+ my %line;
+ ( $line{status}, $line{count} ) = DelShelf($1);
+ (defined $shelflist->{$1}) and delete $shelflist->{$1};
+ # print $query->redirect("/cgi-bin/koha/opac-shelves.pl"); exit;
+ # can't redirect and expect %line to DO anything!
+ push( @paramsloop, \%line );
}
- $template->param(
- shelvesloop => \@shelvesloop,
- shelves => 1,
+ $showadd = 1;
+ $template->param(
+ paramsloop => \@paramsloop,
+ shelves => 1,
);
last SWITCH;
}
}
-# rebuild shelflist in case a shelf has been added
-($shelflist) = GetShelves( $loggedinuser, 2 ) ;
-my $color='';
+# rebuilding shelflist (in case a shelf has been added) is not necessary since add redirects!
+
+$showadd and $template->param(showadd => 1);
+my $color = 0;
my @shelvesloop;
my @shelveslooppriv;
foreach my $element (sort { lc($shelflist->{$a}->{'shelfname'}) cmp lc($shelflist->{$b}->{'shelfname'}) } keys %$shelflist) {
- my %line;
- my %linepriv;
- ($color eq 0) ? ($color=1) : ($color=0);
- if ($shelflist->{$element}->{'category'} eq 2) {
- $line{'toggle'}= $color;
- $line{'shelf'}=$element;
- $line{'shelfname'}=$shelflist->{$element}->{'shelfname'};
- $line{'sortfield'}=$shelflist->{$element}->{'sortfield'};
- $line{"category".$shelflist->{$element}->{'category'}} = 1;
- $line{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser;
- $line{'shelfvirtualcount'}=$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);
- } elsif ($shelflist->{$element}->{'category'} eq 1) {
- $linepriv{'toggle'}= $color;
- $linepriv{'shelf'}=$element;
- $linepriv{'shelfname'}=$shelflist->{$element}->{'shelfname'};
- $linepriv{'sortfield'}=$shelflist->{$element}->{'sortfield'};
- $linepriv{"category".$shelflist->{$element}->{'category'}} = 1;
- $linepriv{'mine'} = 1 if $shelflist->{$element}->{'owner'} eq $loggedinuser;
- $linepriv{'shelfvirtualcount'}=$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);
+ my %line;
+ $color = ($color) ? 0 : 1;
+ $line{'toggle'} = $color;
+ $line{'shelf'} = $element;
+ $line{'shelfname'} = $shelflist->{$element}->{'shelfname'};
+ $line{'sortfield'} = $shelflist->{$element}->{'sortfield'};
+ $line{"category".$shelflist->{$element}->{'category'}} = 1;
+ $line{'shelfvirtualcount'} = $shelflist->{$element}->{'count'};
+ $line{'canmanage'} = ShelfPossibleAction($loggedinuser,$element,'manage');
+ if ($shelflist->{$element}->{'owner'} eq $loggedinuser) {
+ $line{'mine'} = 1;
+ } else {
+ $line{'firstname'} = $shelflist->{$element}->{'firstname'};
+ $line{ 'surname' } = $shelflist->{$element}->{ 'surname' };
+ }
+ if ($shelflist->{$element}->{'category'} eq 2) {
+ push (@shelvesloop, \%line);
+ } elsif ($shelflist->{$element}->{'category'} eq 1) {
+ push (@shelveslooppriv, \%line);
}
}
$template->param(
shelveslooppriv => \@shelveslooppriv,
- shelvesloop => \@shelvesloop,
+ shelvesloop => \@shelvesloop,
"BiblioDefaultView".C4::Context->preference("BiblioDefaultView") => 1,
);