Browse Source

bug 3093: Enhance placing of holds in the staff interface.

This patch allows staff users to request reserves on multiple
items at one time.

Added checkboxes, select-all, clear-all, and place-hold button to
staff search results page.  Place-hold button will only appear if
the user has permission to place holds for others.  Item-level
Place-Hold button will not appear for multiple holds, nor will
the vertical detail menu.

Patron input page now shows multiple items, if applicable.

Hold confirmation page shows results for multiple items, if
applicable.  Those which cannot be reserved are highlighted and
are excluded from the reservation.  The reservation is placed at
the biblio number (i.e. next available) level.

Fixed display of item type.

Removed side menu for multiple items; removed item-oriented button for multiple items.

Signed-off-by: Galen Charlton <galen.charlton@liblime.com>
3.2.x
Stephen Edwards 15 years ago
committed by Galen Charlton
parent
commit
47690dbcc4
  1. 89
      koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl
  2. 282
      koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tmpl
  3. 39
      koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/addbybiblionumber.tmpl
  4. 38
      koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl
  5. 10
      reserve/modrequest.pl
  6. 85
      reserve/placerequest.pl
  7. 627
      reserve/request.pl
  8. 97
      virtualshelves/addbybiblionumber.pl

89
koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tmpl

@ -1,8 +1,11 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Catalog &rsaquo; <!-- TMPL_IF NAME="searchdesc" -->Results of Search <!-- TMPL_IF NAME="query_desc" -->for '<!-- TMPL_VAR NAME="query_desc" -->'<!-- /TMPL_IF --><!-- TMPL_IF NAME="limit_desc" -->&nbsp;with limit(s):&nbsp;'<!-- TMPL_VAR NAME="limit_desc" -->'<!-- /TMPL_IF --><!-- TMPL_ELSE -->You did not specify any search criteria<!-- /TMPL_IF --></title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<!-- TMPL_IF NAME="AmazonEnabled" --><script type="text/javascript">
<script type="text/javascript">
//<![CDATA[
var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
var MSG_NON_RESERVES_SELECTED = _("One or more selected items cannot be reserved.");
<!-- TMPL_IF NAME="AmazonEnabled" -->
// http://www.oreillynet.com/pub/a/javascript/2003/10/21/amazonhacks.html
function verify_images() {
$("img").each(function(i){
@ -14,7 +17,7 @@ function verify_images() {
} else if ((this.complete != null) && (!this.complete)) {
this.src = 'http://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif';
}
}
}
});
}
$(document).ready(function() {
@ -26,8 +29,58 @@ $(document).ready(function() {
$(window).load(function() {
verify_images();
});
//]]>
</script><!-- /TMPL_IF -->
<!-- /TMPL_IF -->
$(document).ready(function() {
$("#selection_ops").show();
$(".selection").show();
});
function selectAll () {
$(".selection").attr("checked", "checked");
}
function clearAll () {
$(".selection").removeAttr("checked");
}
function placeHold () {
var checkedItems = $(".selection:checked");
if ($(checkedItems).size() == 0) {
alert(MSG_NO_ITEM_SELECTED);
return false;
}
var bibs = "";
var badBibs = false;
$(checkedItems).each(function() {
var bib = $(this).val();
if ($("#reserve_" + bib).size() == 0) {
alert(MSG_NON_RESERVES_SELECTED);
badBibs = true;
return false;
}
bibs += bib + "/";
});
if (badBibs) {
return false;
}
$("#hold_form_biblios").val(bibs);
$("#hold_form").submit();
return false;
}
function addToList () {
var checkedItems = $(".selection:checked");
if ($(checkedItems).size() == 0) {
alert(MSG_NO_ITEM_SELECTED);
return false;
}
var bibs = "";
$(checkedItems).each(function() {
bibs += $(this).val() + "/";
});
var url = "/cgi-bin/koha/virtualshelves/addbybiblionumber.pl?biblionumbers=" + bibs;
window.open(url, 'Add_to_virtualshelf', 'width=500, height=400, toolbar=false, scrollbars=yes');
return false;
}
//]]>
</script>
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
@ -79,6 +132,15 @@ $(window).load(function() {
<h3>
<!-- TMPL_VAR NAME="total" --> result(s) found <!-- TMPL_IF NAME="query_desc" -->for <span style="font-weight: bold;">'<!-- TMPL_VAR NAME="query_desc" -->'</span><!-- /TMPL_IF --><!-- TMPL_IF NAME="limit_desc" -->&nbsp;with limit(s): <span style="font-weight: bold;">'<!-- TMPL_VAR NAME="limit_desc" -->'</span><!-- /TMPL_IF --><!-- TMPL_IF NAME="LibraryName" --> in <!-- TMPL_VAR NAME="LibraryName" --> Catalog<!-- /TMPL_IF -->.<br />&nbsp;
</h3>
<div id="selection_ops" style="display:none">
<a href="#" onclick="selectAll(); return false;">Select All</a>
|
<a href="#" onclick="clearAll(); return false;">Clear All</a>
<!-- TMPL_IF NAME="CAN_user_reserveforothers" -->
<input type="button" onclick="placeHold(); return false;" value="Place Hold"/>
<!-- /TMPL_IF -->
<input type="button" onclick="addToList(); return false;" value="Add to List"/>
</div>
</div>
<!-- TMPL_IF NAME="stopwords_removed" --><div><p class="tip">Ignored the following common words: "<!-- TMPL_VAR NAME="stopwords_removed" -->"<p></div><!-- /TMPL_IF -->
<!-- TMPL_ELSE -->
@ -205,7 +267,7 @@ $(window).load(function() {
<table>
<tr>
<!-- TMPL_IF NAME="AmazonEnabled" --><th>&nbsp;</th><!-- /TMPL_IF -->
<th>Results</th>
<th colspan="2">Results</th>
<th>Location</th>
</tr>
<!-- Actual Search Results -->
@ -218,6 +280,9 @@ $(window).load(function() {
<img src="<!-- TMPL_IF NAME="normalized_isbn" -->http://images.amazon.com/images/P/<!-- TMPL_VAR name="normalized_isbn" -->.01.TZZZZZZZ.jpg<!-- TMPL_ELSE -->http://g-images.amazon.com/images/G/01/x-site/icons/no-img-sm.gif<!-- /TMPL_IF -->" alt="image" class="thumbnail" /> <!-- /TMPL_IF -->
</a></td>
<!-- /TMPL_IF -->
<td>
<input type="checkbox" class="selection" value="<!-- TMPL_VAR NAME="biblionumber" -->" style="display:none" />
</td>
<td>
<p><!-- TMPL_VAR NAME="result_number" -->.
<!-- TMPL_IF name="BiblioDefaultViewmarc" -->
@ -287,7 +352,7 @@ $(window).load(function() {
<!-- TMPL_IF NAME="norequests" -->
No holds allowed
<!-- TMPL_ELSE -->
<a class="reserve" href="/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Holds</a>
<a class="reserve" id="reserve_<!-- TMPL_VAR NAME="biblionumber" -->" href="/cgi-bin/koha/reserve/request.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->">Holds</a>
<!-- /TMPL_IF -->
</td>
@ -377,6 +442,18 @@ $(window).load(function() {
</div>
<!-- /TMPL_IF -->
<form id="hold_form" method="get" action="/cgi-bin/koha/reserve/request.pl">
<!-- Value will be set here by placeHold() -->
<input id="hold_form_biblios" type="hidden" name="biblionumbers" value="" />
<input type="hidden" name="multi_hold" value="1"/>
</form>
<form id="list_form" method="get" action="/cgi-bin/koha/reserve/request.pl">
<!-- Value will be set here by addToList() -->
<input id="list_form_biblios" type="hidden" name="biblionumbers" value="" />
<input type="hidden" name="multi_listadd" value="1"/>
</form>
</div>
</div>
<div class="yui-b">

282
koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tmpl

@ -1,5 +1,9 @@
<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Place a hold on <!-- TMPL_VAR NAME="title" escape="html" --></title>
<!-- TMPL_UNLESS NAME="multi_hold" -->
<title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Place a hold on <!-- TMPL_VAR NAME="title" escape="html" --></title>
<!-- TMPL_ELSE -->
<title>Koha &rsaquo; Circulation &rsaquo; Holds &rsaquo; Confirm Holds</title>
<!-- /TMPL_UNLESS -->
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<script type="text/javascript">
// <![CDATA[
@ -11,45 +15,46 @@ var override_items = {<!-- TMPL_LOOP NAME="bibitemloop" --><!-- TMPL_LOOP NAME="
},
<!-- /TMPL_IF --><!-- /TMPL_LOOP --><!-- /TMPL_LOOP -->
};
var MSG_NO_ITEMS_AVAILABLE = _("A hold cannot be requested on any of these items.");
function check() {
var msg = "";
var count_reserv = 0;
var alreadyreserved = 0;
// check if we have checkitem form
if (document.form.checkitem){
for (i=0;i<document.form.checkitem.length;i++){
if (document.form.checkitem[i].checked == true) {
// check if we have checkitem form
if (document.form.checkitem){
for (i=0;i<document.form.checkitem.length;i++){
if (document.form.checkitem[i].checked == true) {
count_reserv++ ;
}
}
// for only one item, check the checkitem without consider the loop checkitem
if (i==0){
if (document.form.checkitem.checked == true) {
count_reserv++;
}
}
}
if (document.form.request.checked == true){
}
// for only one item, check the checkitem without consider the loop checkitem
if (i==0){
if (document.form.checkitem.checked == true) {
count_reserv++;
}
}
}
if (document.form.request.checked == true){
count_reserv++ ;
}
}
if (document.form.alreadyreserved.value == "1"){
if (document.form.alreadyreserved && document.form.alreadyreserved.value == "1"){
alreadyreserved++ ;
}
}
if (count_reserv == "0"){
if (count_reserv == "0"){
msg += (_("- Please select an item to place a hold\n"));
}
if (count_reserv >= "2"){
}
if (count_reserv >= "2"){
msg += (_("- You may only place a hold on one item at a time\n"));
}
}
if (alreadyreserved > "0"){
if (alreadyreserved > "0"){
msg += (_("- This patron had already placed a hold on this item\n Please cancel the previous hold first \n"));
}
}
if (msg == "") return(true);
else {
@ -58,6 +63,32 @@ if (alreadyreserved > "0"){
}
}
function checkMultiHold() {
var spans = $(".multi_hold_item");
if ($(spans).size() == 0) {
alert(MSG_NO_ITEMS_AVAILABLE);
return false;
}
var biblionumbers = "";
$(spans).each(function() {
var bibnum = $(this).attr("title");
biblionumbers += bibnum + "/";
});
var badSpans = $(".not_holdable");
var badBibs = "";
$(badSpans).each(function() {
var bibnum = $(this).attr("title");
badBibs += bibnum + "/";
});
$("#multi_hold_bibs").val(biblionumbers);
$("#bad_bibs").val(badBibs);
return true;
}
$(document).ready(function() {
$("input.needsoverride").click(function() { // This must be before the radio button/checkbox switch logic
var itemnumber = this.value;
@ -104,7 +135,11 @@ if (alreadyreserved > "0"){
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="circ-search.inc" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" escape="html" --></a> &rsaquo; Place a hold on <!-- TMPL_VAR NAME="title" escape="html" --></div>
<!-- TMPL_UNLESS NAME="multi_hold" -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" escape="html" --></a> &rsaquo; Place a hold on <!-- TMPL_VAR NAME="title" escape="html" --></div>
<!-- TMPL_ELSE -->
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/catalogue/search.pl">Catalog</a> &rsaquo; Confirm Holds</div>
<!-- /TMPL_UNLESS -->
<div id="doc3" class="yui-t2">
@ -116,7 +151,7 @@ if (alreadyreserved > "0"){
<strong>Cannot reserve:</strong> this record has no items attached.
</div>
<!-- TMPL_ELSE -->
<!-- TMPL_IF NAME="messagetransfert" -->
<!-- TMPL_IF NAME="messagetransfert" -->
<div class="dialog message">
<h2>Hold found for (<!-- TMPL_VAR NAME="nextreservtitle" -->), please transfer</h2>
<p>Hold placed by : <strong> <!-- TMPL_VAR NAME="nextreservsurname" --> <!-- TMPL_VAR NAME="nextreservfirstname" --></strong> at : <strong> <!-- TMPL_VAR NAME="branchname" --> </strong>, Please transfer this item.
@ -125,10 +160,15 @@ if (alreadyreserved > "0"){
<input type="submit" class="button" />
</form>
</div>
<!-- /TMPL_IF -->
<h1>Place a hold on <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" escape="html" --></a></h1>
<!-- /TMPL_IF -->
<!-- TMPL_UNLESS NAME="multi_hold" -->
<h1>Place a hold on <a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" escape="html" --></a></h1>
<!-- TMPL_ELSE -->
<h1>Confirm Holds</h1>
<!-- /TMPL_UNLESS -->
<!-- TMPL_UNLESS NAME="cardnumber"-->
<!-- TMPL_UNLESS NAME="cardnumber"-->
<!-- TMPL_IF NAME="messageborrower" -->
<div class="dialog alert"><h3>Patron Not Found</h3><p>No patron with this name, Please, try another</p> </div>
<!-- /TMPL_IF -->
@ -147,26 +187,34 @@ if (alreadyreserved > "0"){
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber"-->" /><fieldset class="action"><input type="submit" value="Select" /></fieldset></fieldset>
<!-- /TMPL_UNLESS -->
<!-- TMPL_IF NAME="multi_hold" -->
<input type="hidden" name="multi_hold" value="<!-- TMPL_VAR NAME="multi_hold" -->"/>
<input type="hidden" name="biblionumbers" value="<!-- TMPL_VAR NAME="biblionumbers" -->"/>
<!-- /TMPL_IF -->
</form>
<!-- TMPL_ELSE -->
<!-- TMPL_ELSE -->
<!-- TMPL_IF NAME="warnings" -->
<div class="dialog alert">
<h3>Cannot Place Hold</h3>
<ul>
<!-- TMPL_IF NAME="maxreserves" -->
<li><strong>Too Many Holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="borrowerfirstname" --> <!-- TMPL_VAR NAME="borrowersurname" --> </a> has too many holds.</li>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="alreadyreserved" -->
<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="borrowerfirstname" --> <!-- TMPL_VAR NAME="borrowersurname" --></a> <strong>already has a hold</strong> on this item </li>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="none_available" -->
<li> <strong>No copies are available</strong> to be placed on hold</li>
<!-- /TMPL_IF -->
<!-- TMPL_UNLESS NAME="multi_hold" -->
<h3>Cannot Place Hold</h3>
<ul>
<!-- TMPL_IF NAME="maxreserves" -->
<li><strong>Too Many Holds: </strong> <a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="borrowerfirstname" --> <!-- TMPL_VAR NAME="borrowersurname" --> </a> has too many holds.</li>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="alreadyreserved" -->
<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="borrowerfirstname" --> <!-- TMPL_VAR NAME="borrowersurname" --></a> <strong>already has a hold</strong> on this item </li>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="none_available" -->
<li> <strong>No copies are available</strong> to be placed on hold</li>
<!-- /TMPL_IF -->
</ul>
<!-- TMPL_ELSE -->
<h3>Cannot Place Hold on Some Items</h3>
<!-- /TMPL_UNLESS -->
</ul></div>
</div>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="messages" -->
@ -188,13 +236,30 @@ if (alreadyreserved > "0"){
<fieldset class="rows left">
<legend>Hold details</legend>
<form action="placerequest.pl" method="post" onsubmit="return check();" name="form">
<!-- TMPL_UNLESS NAME="multi_hold" -->
<form action="placerequest.pl" method="post" onsubmit="return check();" name="form">
<!-- TMPL_ELSE -->
<form action="placerequest.pl" method="post" onsubmit="return checkMultiHold();" name="form">
<!-- /TMPL_UNLESS -->
<input type="hidden" size="10" name="member" value="<!-- TMPL_VAR NAME="cardnumber" -->" />
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
<input type="hidden" name="type" value="str8" />
<input type="hidden" name="title" value="<!-- TMPL_VAR NAME="title" -->" />
<input type="hidden" name="rank-request" value="<!-- TMPL_VAR NAME="fixedRank" -->" />
<!-- TMPL_IF NAME="multi_hold" -->
<input type="hidden" name="multi_hold" value="<!-- TMPL_VAR NAME="multi_hold" -->"/>
<input type="hidden" name="biblionumbers" id="multi_hold_bibs" value="<!-- TMPL_VAR NAME="biblionumbers" -->"/>
<input type="hidden" name="bad_bibs" id="bad_bibs" value=""/>
<input type="hidden" name="request" value="any"/>
<!-- TMPL_LOOP NAME="biblioloop" -->
<input type="hidden" name="title_<!-- TMPL_VAR NAME="biblionumber">" value="<!-- TMPL_VAR NAME="title">"/>
<input type="hidden" name="rank_<!-- TMPL_VAR NAME="biblionumber">" value="<!-- TMPL_VAR NAME="rank">"/>
<!-- /TMPL_LOOP -->
<!-- TMPL_ELSE -->
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
<input type="hidden" name="title" value="<!-- TMPL_VAR NAME="title" -->" />
<input type="hidden" name="rank-request" value="<!-- TMPL_VAR NAME="fixedRank" -->" />
<!-- /TMPL_IF -->
<ol> <li><span class="label">Patron:</span>
<!-- TMPL_IF NAME="cardnumber"-->
<a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="borrowerfirstname" --> <!-- TMPL_VAR NAME="borrowersurname" --> (<!-- TMPL_VAR NAME="cardnumber" -->)</a>
@ -202,10 +267,12 @@ if (alreadyreserved > "0"){
Not defined yet
<!-- /TMPL_IF -->
</li>
<li>
<span class="label">Priority:</span>
<strong><!-- TMPL_VAR Name="fixedRank" --></strong>
</li>
<!-- TMPL_UNLESS NAME="multi_hold" -->
<li>
<span class="label">Priority:</span>
<strong><!-- TMPL_VAR Name="fixedRank" --></strong>
</li>
<!-- /TMPL_UNLESS -->
<li>
<label for="holdnotes">Notes:</label>
<textarea id="holdnotes" name="notes" cols="30" rows="1"></textarea>
@ -215,13 +282,16 @@ if (alreadyreserved > "0"){
<!-- TMPL_VAR NAME="CGIbranch" -->
</li>
<li> <label for="requestany">Place a hold on the next available copy </label>
<!-- TMPL_UNLESS NAME="multi_hold" -->
<li> <label for="requestany">Place a hold on the next available copy </label>
<input type="checkbox" id="requestany" name="request" checked="checked" value="Any" />
<input type="hidden" name="biblioitem" value="<!-- TMPL_VAR NAME="biblioitemnumber" -->" />
<input type="hidden" name="alreadyreserved" value="<!-- TMPL_VAR NAME="alreadyreserved" -->" />
</li>
</li>
<!-- /TMPL_UNLESS -->
</ol>
<!-- TMPL_UNLESS NAME="multi_hold" -->
<fieldset class="action">
<!-- TMPL_IF NAME="cardnumber"-->
<!-- TMPL_IF NAME="override_required" -->
@ -234,12 +304,13 @@ if (alreadyreserved > "0"){
<!-- /TMPL_IF -->
</fieldset>
<!-- TMPL_LOOP name="bibitemloop" -->
<ol>
<!-- TMPL_UNLESS NAME="item-level_itypes" -->
<li><span class="label">Item type:</span> <!-- TMPL_VAR NAME="description" --></li>
<!-- /TMPL_UNLESS -->
<!-- TMPL_IF NAME="publicationyear" --><li><span class="label">Publication year:</span> <!-- TMPL_VAR NAME="publicationyear" --></li><!-- /TMPL_IF -->
</ol>
<ol>
<!-- TMPL_UNLESS NAME="item-level_itypes" -->
<li><span class="label">Item type:</span> <!-- TMPL_VAR NAME="description" --></li>
<!-- /TMPL_UNLESS -->
<!-- TMPL_IF NAME="publicationyear" --><li><span class="label">Publication year:</span> <!-- TMPL_VAR NAME="publicationyear" --></li><!-- /TMPL_IF -->
</ol>
<table id="requestspecific">
<caption>Place a hold on a specific copy</caption>
@ -322,7 +393,75 @@ if (alreadyreserved > "0"){
</tr>
<!-- /TMPL_LOOP --> <!-- itemloop -->
</table>
<!-- /TMPL_LOOP --> <!-- bibitemloop -->
<!-- TMPL_ELSE --><!-- UNLESS multi_hold -->
<table id="requesttitles">
<tr>
<th>Title</th>
<!-- TMPL_UNLESS NAME="item-level_itypes" -->
<th>Item Type</th>
<!-- /TMPL_UNLESS -->
<th>Priority</th>
<th>Information</th>
</tr>
<!-- TMPL_LOOP NAME="biblioloop" -->
<!-- TMPL_IF NAME="warn" -->
<tr class="onissue">
<!-- TMPL_ELSE -->
<tr>
<!-- /TMPL_IF -->
<td>
<ul>
<li><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" --></a></li>
<!-- TMPL_IF NAME="publicationyear" -->
<li><span class="label">Publication year:</span> <!-- TMPL_VAR NAME="publicationyear" --></li>
<!-- /TMPL_IF -->
</ul>
<!-- TMPL_UNLESS NAME="warn" -->
<span class="multi_hold_item" title="<!-- TMPL_VAR NAME="biblionumber" -->"></span>
<!-- TMPL_ELSE -->
<span class="not_holdable" title="<!-- TMPL_VAR NAME="biblionumber" -->"></span>
<!-- /TMPL_UNLESS -->
</td>
<!-- TMPL_UNLESS NAME="item-level_itypes" -->
<td>
<img src="<!-- TMPL_VAR name="imageurl" -->" alt="<!-- TMPL_VAR NAME="itypename" -->" title="<!-- TMPL_VAR NAME="itypename" -->" />
</td>
<!-- /TMPL_UNLESS -->
<td><!-- TMPL_VAR NAME="rank" --></td>
<td>
<!-- TMPL_IF NAME="alreadyres" -->
<ul>
<!-- TMPL_ELSE -->
<!-- TMPL_IF NAME="none_avail" -->
<ul>
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="alreadyres" -->
<li><a href="/cgi-bin/koha/members/moremember.pl?borrowernumber=<!-- TMPL_VAR NAME="borrowernumber" -->"><!-- TMPL_VAR NAME="borrowerfirstname" --> <!-- TMPL_VAR NAME="borrowersurname" --></a> <strong>already has a hold</strong> on this item </li>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="none_avail" -->
<li> <strong>No copies are available</strong> to be placed on hold</li>
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="alreadyres" -->
</ul>
<!-- TMPL_ELSE -->
<!-- TMPL_IF NAME="none_avail" -->
</ul>
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
</td>
</tr>
<!-- /TMPL_LOOP -->
</table>
<!-- /TMPL_UNLESS --><!-- /multi_hold -->
<fieldset class="action">
<!-- TMPL_IF NAME="cardnumber"-->
@ -335,16 +474,28 @@ if (alreadyreserved > "0"){
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
</fieldset>
</fieldset>
</form>
</fieldset>
<!-- /TMPL_UNLESS -->
<!-- TMPL_UNLESS NAME="cardnumber" -->
<!-- TMPL_IF name="reserveloop" -->
<form name="T<!-- TMPL_VAR NAME="time" -->" action="modrequest.pl" method="post">
<!-- TMPL_IF NAME="multi_hold" -->
<input type = "hidden" name="multi_hold" value="1"/>
<input type = "hidden" name="biblionumbers" value="<!-- TMPL_VAR NAME="biblionumbers" -->"/>
<!-- /TMPL_IF -->
<fieldset class="rows left">
<legend>Existing holds</legend>
<!-- TMPL_LOOP NAME="biblioloop" -->
<!-- TMPL_IF NAME="reserveloop" -->
<table>
<!-- TMPL_IF NAME="multi_hold" -->
<caption><a href="/cgi-bin/koha/catalogue/detail.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"><!-- TMPL_VAR NAME="title" --></a></caption>
<!-- /TMPL_IF -->
<tr>
<th>Priority</th>
<th>Patron</th>
@ -435,7 +586,12 @@ if (alreadyreserved > "0"){
</tr>
<!-- /TMPL_LOOP --> <!-- existing reserveloop -->
</table>
<fieldset class="action"><input type="submit" name="submit" value="Update hold(s)" /></fieldset>
<!-- /TMPL_IF --><!-- /reserveloop -->
<!-- /TMPL_LOOP --><!-- /biblioloop -->
<fieldset class="action">
<input type="submit" name="submit" value="Update hold(s)" />
</fieldset>
</fieldset>
</form>
<!-- /TMPL_IF -->
@ -445,7 +601,9 @@ if (alreadyreserved > "0"){
</div>
<div class="yui-b">
<!-- TMPL_INCLUDE NAME="biblio-view-menu.inc" -->
<!-- TMPL_UNLESS NAME="multi_hold" -->
<!-- TMPL_INCLUDE NAME="biblio-view-menu.inc" -->
<!-- /TMPL_UNLESS -->
</div>
</div>

39
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/addbybiblionumber.tmpl

@ -10,22 +10,45 @@
<div id="custom-doc" class="yui-t7">
<div id="bd">
<h3>Add
<!-- TMPL_UNLESS NAME="biblioloop" -->
<h3>Add
<i><!-- TMPL_VAR NAME="title" escape="html" --></i>
<!-- TMPL_IF NAME="author" -->
by <!-- TMPL_VAR NAME="author" -->
<!-- /TMPL_IF --> to a list
</h3>
</h3>
<!-- TMPL_ELSE -->
<h3>Add to a list:</h3>
<h4>
<ul>
<!-- TMPL_LOOP NAME="biblioloop" -->
<li>
<i><!-- TMPL_VAR NAME="title" escape="html" --></i>
<!-- TMPL_IF NAME="author" -->
by <!-- TMPL_VAR NAME="author" -->
<!-- /TMPL_IF -->
</li>
<!-- /TMPL_LOOP -->
</ul>
</h4>
<!-- /TMPL_UNLESS -->
<!-- TMPL_IF NAME="CGIvirtualshelves" --><form name="f1" method="post" action="/cgi-bin/koha/virtualshelves/addbybiblionumber.pl">
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
<!-- TMPL_UNLESS NAME="biblionumbers" -->
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
<!-- TMPL_ELSE -->
<input type="hidden" name="biblionumbers" value="<!-- TMPL_VAR NAME="biblionumbers" -->" />
<!-- /TMPL_UNLESS -->
<fieldset class="rows">
<legend>Select an existing list</legend>
<ol>
<li><label>Choose list</label><!-- TMPL_VAR NAME="CGIvirtualshelves" --></li>
</ol>
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
<!-- TMPL_UNLESS NAME="biblionumbers" -->
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
<!-- TMPL_ELSE -->
<input type="hidden" name="biblionumbers" value="<!-- TMPL_VAR NAME="biblionumbers" -->" />
<!-- /TMPL_UNLESS -->
<fieldset class="action"><input type="submit" value="Save" class="submit" /></fieldset>
</fieldset>
</form>
@ -37,7 +60,11 @@
<label for="newvirtualshelf">
List name:
</label>
<input type="hidden" name="biblionumber" id="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
<!-- TMPL_UNLESS NAME="biblionumbers" -->
<input type="hidden" name="biblionumber" id="biblionumber" value="<!-- TMPL_VAR NAME="biblionumber" -->" />
<!-- TMPL_ELSE -->
<input type="hidden" name="biblionumbers" id="biblionumbers" value="<!-- TMPL_VAR NAME="biblionumbers" -->" />
<!-- /TMPL_UNLESS -->
<input type="text" name="newvirtualshelf" id="newvirtualshelf" size="40" />
</li>
<li>

38
koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tmpl

@ -5,6 +5,8 @@
<script type="text/javascript">
//<![CDATA[
var MSG_NO_ITEM_SELECTED = _("Nothing is selected.");
$(document).ready(function(){
$("#addbarcode").focus();
$("span.clearall").html("<a id=\"CheckNone\" href=\"/cgi-bin/koha/shelves.pl\">Clear All<\/a>");
@ -17,6 +19,7 @@ $(document).ready(function(){
$(".checkboxed").unCheckCheckboxes();
return false;
});
$("#placehold").show();
});
function confirmDelete(message){
@ -55,7 +58,22 @@ $(document).ready(function(){
}
return true;
}
//]]>
function placeHold () {
var checkedItems = $(".selection:checked");
if ($(checkedItems).size() == 0) {
alert(MSG_NO_ITEM_SELECTED);
return false;
}
var bibs = "";
$(checkedItems).each(function() {
bibs += $(this).val() + "/";
});
$("#hold_form_biblios").val(bibs);
$("#hold_form").submit();
return false;
}
//]]>
</script>
</head>
<body>
@ -107,7 +125,12 @@ $(document).ready(function(){
<input type="hidden" name="modifyshelfcontents" value="1" />
<fieldset>
<legend>Contents of <i><!-- TMPL_VAR NAME="shelfname" --></i></legend>
<!--TMPL_IF NAME="manageshelf" --><p><span class="checkall"></span><span class="clearall"></span></p><!-- /TMPL_IF -->
<!--TMPL_IF NAME="manageshelf" -->
<p>
<span class="checkall"></span>
<span class="clearall"></span>
</p>
<!-- /TMPL_IF -->
<!-- TMPL_VAR name='pagination_bar'-->
<table>
<tr>
@ -128,9 +151,9 @@ $(document).ready(function(){
<td>
<!-- TMPL_IF NAME="confirm" -->
<input type="hidden" name="CONFIRM-<!-- TMPL_VAR NAME="confirm" -->" />
<input type="checkbox" name="REM-<!-- TMPL_VAR NAME="biblionumber" -->" checked />
<input type="checkbox" class="selection" value="<!-- TMPL_VAR NAME="biblionumber" -->" name="REM-<!-- TMPL_VAR NAME="biblionumber" -->" checked />
<!-- TMPL_ELSE -->
<input type="checkbox" name="REM-<!-- TMPL_VAR NAME="biblionumber" -->" />
<input type="checkbox" class="selection" value="<!-- TMPL_VAR NAME="biblionumber" -->" name="REM-<!-- TMPL_VAR NAME="biblionumber" -->" />
<!-- /TMPL_IF -->
</td>
<!-- /TMPL_IF -->
@ -162,6 +185,7 @@ $(document).ready(function(){
</fieldset>
<fieldset class="action">
<!-- TMPL_IF name="manageshelf" -->
<input type="button" id="placehold" style="display:none" onclick="placeHold(); return false;" value="Place Hold"/>
<input type="submit" value="Remove selected Items" onclick='return confirm(_("Are you sure you want to remove these items from the shelf?"))' />
<!-- /TMPL_IF -->
</fieldset>
@ -379,6 +403,12 @@ $(document).ready(function(){
</div>
<!-- /TMPL_UNLESS -->
<form id="hold_form" method="get" action="/cgi-bin/koha/reserve/request.pl"/>
<!-- Value will be set here by placeHold() -->
<input id="hold_form_biblios" type="hidden" name="biblionumbers" value="" />
<input type="hidden" name="multi_hold" value="1"/>
</form>
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->

10
reserve/modrequest.pl

@ -46,6 +46,8 @@ my @biblionumber=$query->param('biblionumber');
my @borrower=$query->param('borrowernumber');
my @branch=$query->param('pickup');
my @itemnumber=$query->param('itemnumber');
my $multi_hold = $query->param('multi_hold');
my $biblionumbers = $query->param('biblionumbers');
my $count=@rank;
my $CancelBiblioNumber=$query->param('CancelBiblioNumber');
@ -71,5 +73,11 @@ my $from=$query->param('from');
if ($from eq 'borrower'){
print $query->redirect("/cgi-bin/koha/members/moremember.pl?borrowernumber=$borrower[0]");
} else {
print $query->redirect("/cgi-bin/koha/reserve/request.pl?biblionumber=$biblionumber[0]");
my $url = "/cgi-bin/koha/reserve/request.pl?";
if ($multi_hold) {
$url .= "multi_hold=1&biblionumbers=$biblionumbers";
} else {
$url .= "biblionumber=$biblionumber[0]";
}
print $query->redirect($url);
}

85
reserve/placerequest.pl

@ -34,6 +34,7 @@ use C4::Members;
my $input = new CGI;
#print $input->header;
my @bibitems=$input->param('biblioitem');
# FIXME I think reqbib does not exist anymore, it's used in line 82, to AddReserve of contraint type 'o'
# I bet it's a 2.x feature, reserving a given biblioitem, that is useless in Koha 3.0
@ -49,9 +50,24 @@ my $type=$input->param('type');
my $title=$input->param('title');
my $borrowernumber=GetMember($borrower,'cardnumber');
my $checkitem=$input->param('checkitem');
my $multi_hold = $input->param('multi_hold');
my $biblionumbers = $multi_hold ? $input->param('biblionumbers') : ($biblionumber . '/');
my $bad_bibs = $input->param('bad_bibs');
my %bibinfos = ();
my @biblionumbers = split '/', $biblionumbers;
foreach my $bibnum (@biblionumbers) {
my %bibinfo = ();
$bibinfo{title} = $input->param("title_$bibnum");
$bibinfo{rank} = $input->param("rank_$bibnum");
$bibinfos{$bibnum} = \%bibinfo;
}
my $found;
#if we have an item selectionned, and the pickup branch is the same as the holdingbranch of the document, we force the value $rank and $found .
# if we have an item selectionned, and the pickup branch is the same as the holdingbranch
# of the document, we force the value $rank and $found .
if ($checkitem ne ''){
$rank[0] = '0' unless C4::Context->preference('ReservesNeedReturns');
my $item = $checkitem;
@ -62,31 +78,48 @@ if ($checkitem ne ''){
}
if ($type eq 'str8' && $borrowernumber ne ''){
my $count=@bibitems;
@bibitems=sort @bibitems;
my $i2=1;
my @realbi;
$realbi[0]=$bibitems[0];
for (my $i=1;$i<$count;$i++) {
my $i3=$i2-1;
if ($realbi[$i3] ne $bibitems[$i]) {
$realbi[$i2]=$bibitems[$i];
$i2++;
}
}
my $const;
if ($input->param('request') eq 'any'){
# place a request on 1st available
AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$notes,$title,$checkitem,$found);
} elsif ($reqbib[0] ne ''){
# FIXME : elsif probably never reached, (see top of the script)
# place a request on a given item
AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'o',\@reqbib,$rank[0],$notes,$title,$checkitem, $found);
} else {
AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$notes,$title,$checkitem, $found);
}
print $input->redirect("request.pl?biblionumber=$biblionumber");
foreach my $biblionumber (keys %bibinfos) {
my $count=@bibitems;
@bibitems=sort @bibitems;
my $i2=1;
my @realbi;
$realbi[0]=$bibitems[0];
for (my $i=1;$i<$count;$i++) {
my $i3=$i2-1;
if ($realbi[$i3] ne $bibitems[$i]) {
$realbi[$i2]=$bibitems[$i];
$i2++;
}
}
my $const;
if ($multi_hold) {
my $bibinfo = $bibinfos{$biblionumber};
AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',[$biblionumber],
$bibinfo->{rank},$notes,$bibinfo->{title},$checkitem,$found);
} else {
if ($input->param('request') eq 'any'){
# place a request on 1st available
AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$notes,$title,$checkitem,$found);
} elsif ($reqbib[0] ne ''){
# FIXME : elsif probably never reached, (see top of the script)
# place a request on a given item
AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'o',\@reqbib,$rank[0],$notes,$title,$checkitem, $found);
} else {
AddReserve($branch,$borrowernumber->{'borrowernumber'},$biblionumber,'a',\@realbi,$rank[0],$notes,$title,$checkitem, $found);
}
}
}
if ($multi_hold) {
if ($bad_bibs) {
$biblionumbers .= $bad_bibs;
}
print $input->redirect("request.pl?biblionumbers=$biblionumbers&multi_hold=1");
} else {
print $input->redirect("request.pl?biblionumber=$biblionumber");
}
} elsif ($borrowernumber eq ''){
print $input->header();
print "Invalid card number please try again";

627
reserve/request.pl

@ -54,13 +54,30 @@ my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
}
);
my $multihold = $input->param('multi_hold');
$template->param(multi_hold => $multihold);
# get Branches and Itemtypes
my $branches = GetBranches();
my $itemtypes = GetItemTypes();
# get biblio information....
my $biblionumber = $input->param('biblionumber');
my $dat = GetBiblioData($biblionumber);
my $default = C4::Context->userenv->{branch};
my @values;
my %label_of;
foreach my $branchcode (sort keys %{$branches} ) {
push @values, $branchcode;
$label_of{$branchcode} = $branches->{$branchcode}->{branchname};
}
my $CGIbranch = CGI::scrolling_list(
-name => 'pickup',
-id => 'pickup',
-values => \@values,
-default => $default,
-labels => \%label_of,
-size => 1,
-multiple => 0,
);
# Select borrowers infos
my $findborrower = $input->param('findborrower');
@ -181,321 +198,355 @@ if ($borrowerslist) {
);
}
# get existing reserves .....
my ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber);
my $totalcount = $count;
my $alreadyreserved;
# FIXME launch another time GetMemberDetails perhaps until
my $borrowerinfo = GetMemberDetails( 0, $cardnumber );
foreach my $res (@$reserves) {
if ( ( $res->{found} eq 'W' ) ) {
$count--;
}
if ( $borrowerinfo->{borrowernumber} eq $res->{borrowernumber} ) {
$warnings = 1;
$alreadyreserved = 1;
}
}
$template->param( alreadyreserved => $alreadyreserved,
messages => $messages,
warnings => $warnings );
# FIXME think @optionloop, is maybe obsolete, or must be switchable by a systeme preference fixed rank or not
# make priorities options
my @optionloop;
for ( 1 .. $count + 1 ) {
push(
@optionloop,
{
num => $_,
selected => ( $_ == $count + 1 ),
}
);
}
# adding a fixed value for priority options
my $fixedRank = $count+1;
my @branchcodes;
my %itemnumbers_of_biblioitem;
my @itemnumbers;
if (my $items = get_itemnumbers_of($biblionumber)->{$biblionumber}){
@itemnumbers = @$items;
}
else {
$template->param('noitems' => 1);
}
my $iteminfos_of = GetItemInfosOf(@itemnumbers);
foreach my $itemnumber (@itemnumbers) {
my $biblioitemnumber = $iteminfos_of->{$itemnumber}->{biblioitemnumber};
push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber );
my @biblionumbers = ();
my $biblionumbers = $input->param('biblionumbers');
if ($multihold) {
@biblionumbers = split '/', $biblionumbers;
} else {
push @biblionumbers, $input->param('biblionumber');
}
my @biblioitemnumbers = keys %itemnumbers_of_biblioitem;
my $notforloan_label_of = get_notforloan_label_of();
my $biblioiteminfos_of = GetBiblioItemInfosOf(@biblioitemnumbers);
my @bibitemloop;
my @biblioloop = ();
foreach my $biblionumber (@biblionumbers) {
foreach my $biblioitemnumber (@biblioitemnumbers) {
my $biblioitem = $biblioiteminfos_of->{$biblioitemnumber};
my $num_available;
my $num_override;
my %biblioloopiter = ();
$biblioitem->{description} =
$itemtypes->{ $biblioitem->{itemtype} }{description};
my $dat = GetBiblioData($biblionumber);
foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) {
my $item = $iteminfos_of->{$itemnumber};
# get existing reserves .....
my ( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber);
my $totalcount = $count;
my $alreadyreserved;
unless (C4::Context->preference('item-level_itypes')) {
$item->{itype} = $biblioitem->{itemtype};
foreach my $res (@$reserves) {
if ( ( $res->{found} eq 'W' ) ) {
$count--;
}
$item->{itypename} = $itemtypes->{ $item->{itype} }{description};
$item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
$item->{homebranchname} = $branches->{ $item->{homebranch} }{branchname};
# if the holdingbranch is different than the homebranch, we show the
# holdingbranch of the document too
if ( $item->{homebranch} ne $item->{holdingbranch} ) {
$item->{holdingbranchname} =
$branches->{ $item->{holdingbranch} }{branchname};
if ( $borrowerinfo->{borrowernumber} eq $res->{borrowernumber} ) {
$warnings = 1;
$alreadyreserved = 1;
$biblioloopiter{warn} = 1;
$biblioloopiter{alreadyres} = 1;
}
# add information
$item->{itemcallnumber} = $item->{itemcallnumber};
# if the item is currently on loan, we display its return date and
# change the background color
my $issues= GetItemIssue($itemnumber);
if ( $issues->{'date_due'} ) {
$item->{date_due} = format_date($issues->{'date_due'});
$item->{backgroundcolor} = 'onloan';
}
# checking reserve
my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($itemnumber);
my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0);
if ( defined $reservedate ) {
$item->{backgroundcolor} = 'reserved';
$item->{reservedate} = format_date($reservedate);
$item->{ReservedForBorrowernumber} = $reservedfor;
$item->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'};
$item->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'};
$item->{ExpectedAtLibrary} = $branches->{$expectedAt}{branchname};
}
# Management of the notforloan document
if ( $item->{notforloan} ) {
$item->{backgroundcolor} = 'other';
$item->{notforloanvalue} =
$notforloan_label_of->{ $item->{notforloan} };
}
# Management of lost or long overdue items
if ( $item->{itemlost} ) {
# FIXME localized strings should never be in Perl code
$item->{message} =
$item->{itemlost} == 1 ? "(lost)"
: $item->{itemlost} == 2 ? "(long overdue)"
: "";
$item->{backgroundcolor} = 'other';
}
# Check the transit status
my ( $transfertwhen, $transfertfrom, $transfertto ) =
GetTransfers($itemnumber);
}
if ( $transfertwhen ne '' ) {
$item->{transfertwhen} = format_date($transfertwhen);
$item->{transfertfrom} =
$branches->{$transfertfrom}{branchname};
$item->{transfertto} = $branches->{$transfertto}{branchname};
$item->{nocancel} = 1;
}
$template->param( alreadyreserved => $alreadyreserved,
messages => $messages,
warnings => $warnings );
# FIXME think @optionloop, is maybe obsolete, or must be switchable by a systeme preference fixed rank or not
# make priorities options
my @optionloop;
for ( 1 .. $count + 1 ) {
push(
@optionloop,
{
num => $_,
selected => ( $_ == $count + 1 ),
}
);
}
# adding a fixed value for priority options
my $fixedRank = $count+1;
# If there is no loan, return and transfer, we show a checkbox.
$item->{notforloan} = $item->{notforloan} || 0;
my @branchcodes;
my %itemnumbers_of_biblioitem;
my @itemnumbers;
# if independent branches is on we need to check if the person can reserve
# for branches they arent logged in to
if ( C4::Context->preference("IndependantBranches") ) {
if (! C4::Context->preference("canreservefromotherbranches")){
# cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
my $userenv = C4::Context->userenv;
if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
$item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
## $items is array of 'item' table numbers
if (my $items = get_itemnumbers_of($biblionumber)->{$biblionumber}){
@itemnumbers = @$items;
}
else {
$template->param('noitems' => 1);
$biblioloopiter{noitems} = 1;
}
## Hash of item number to 'item' table fields
my $iteminfos_of = GetItemInfosOf(@itemnumbers);
## Here we go backwards again to create hash of biblioitemnumber to itemnumbers,
## when by definition all of the itemnumber have the same biblioitemnumber
foreach my $itemnumber (@itemnumbers) {
my $biblioitemnumber = $iteminfos_of->{$itemnumber}->{biblioitemnumber};
push( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} }, $itemnumber );
}
## Should be same as biblionumber
my @biblioitemnumbers = keys %itemnumbers_of_biblioitem;
my $notforloan_label_of = get_notforloan_label_of();
## Hash of biblioitemnumber to 'biblioitem' table records
my $biblioiteminfos_of = GetBiblioItemInfosOf(@biblioitemnumbers);
my @bibitemloop;
foreach my $biblioitemnumber (@biblioitemnumbers) {
my $biblioitem = $biblioiteminfos_of->{$biblioitemnumber};
my $num_available;
my $num_override;
$biblioitem->{description} =
$itemtypes->{ $biblioitem->{itemtype} }{description};
$biblioloopiter{description} = $biblioitem->{description};
$biblioloopiter{itypename} = $biblioitem->{description};
$biblioloopiter{imageurl} =
getitemtypeimagelocation('intranet', $itemtypes->{$biblioitem->{itemtype}}{imageurl});
foreach my $itemnumber ( @{ $itemnumbers_of_biblioitem{$biblioitemnumber} } ) {
my $item = $iteminfos_of->{$itemnumber};
unless (C4::Context->preference('item-level_itypes')) {
$item->{itype} = $biblioitem->{itemtype};
}
$item->{itypename} = $itemtypes->{ $item->{itype} }{description};
$item->{imageurl} = getitemtypeimagelocation( 'intranet', $itemtypes->{ $item->{itype} }{imageurl} );
$item->{homebranchname} = $branches->{ $item->{homebranch} }{branchname};
# if the holdingbranch is different than the homebranch, we show the
# holdingbranch of the document too
if ( $item->{homebranch} ne $item->{holdingbranch} ) {
$item->{holdingbranchname} =
$branches->{ $item->{holdingbranch} }{branchname};
}
# add information
$item->{itemcallnumber} = $item->{itemcallnumber};
# if the item is currently on loan, we display its return date and
# change the background color
my $issues= GetItemIssue($itemnumber);
if ( $issues->{'date_due'} ) {
$item->{date_due} = format_date($issues->{'date_due'});
$item->{backgroundcolor} = 'onloan';
}
# checking reserve
my ($reservedate,$reservedfor,$expectedAt) = GetReservesFromItemnumber($itemnumber);
my $ItemBorrowerReserveInfo = GetMemberDetails( $reservedfor, 0);
if ( defined $reservedate ) {
$item->{backgroundcolor} = 'reserved';
$item->{reservedate} = format_date($reservedate);
$item->{ReservedForBorrowernumber} = $reservedfor;
$item->{ReservedForSurname} = $ItemBorrowerReserveInfo->{'surname'};
$item->{ReservedForFirstname} = $ItemBorrowerReserveInfo->{'firstname'};
$item->{ExpectedAtLibrary} = $branches->{$expectedAt}{branchname};
}
# Management of the notforloan document
if ( $item->{notforloan} ) {
$item->{backgroundcolor} = 'other';
$item->{notforloanvalue} =
$notforloan_label_of->{ $item->{notforloan} };
}
# Management of lost or long overdue items
if ( $item->{itemlost} ) {
# FIXME localized strings should never be in Perl code
$item->{message} =
$item->{itemlost} == 1 ? "(lost)"
: $item->{itemlost} == 2 ? "(long overdue)"
: "";
$item->{backgroundcolor} = 'other';
}
# Check the transit status
my ( $transfertwhen, $transfertfrom, $transfertto ) =
GetTransfers($itemnumber);
if ( $transfertwhen ne '' ) {
$item->{transfertwhen} = format_date($transfertwhen);
$item->{transfertfrom} =
$branches->{$transfertfrom}{branchname};
$item->{transfertto} = $branches->{$transfertto}{branchname};
$item->{nocancel} = 1;
}
# If there is no loan, return and transfer, we show a checkbox.
$item->{notforloan} = $item->{notforloan} || 0;
# if independent branches is on we need to check if the person can reserve
# for branches they arent logged in to
if ( C4::Context->preference("IndependantBranches") ) {
if (! C4::Context->preference("canreservefromotherbranches")){
# cant reserve items so need to check if item homebranch and userenv branch match if not we cant reserve
my $userenv = C4::Context->userenv;
if ( ($userenv) && ( $userenv->{flags} != 1 ) ) {
$item->{cantreserve} = 1 if ( $item->{homebranch} ne $userenv->{branch} );
}
}
}
}
my $branchitemrule = GetBranchItemRule( $item->{'homebranch'}, $item->{'itype'} );
my $policy_holdallowed = 1;
$item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
if ( $branchitemrule->{'holdallowed'} == 0 ||
( $branchitemrule->{'holdallowed'} == 1 && $borrowerinfo->{'branchcode'} ne $item->{'homebranch'} ) ) {
$policy_holdallowed = 0;
}
if (IsAvailableForItemLevelRequest($itemnumber) and not $item->{cantreserve}) {
if ( not $policy_holdallowed and C4::Context->preference( 'AllowHoldPolicyOverride' ) ) {
$item->{override} = 1;
$num_override++;
} elsif ( $policy_holdallowed ) {
$item->{available} = 1;
$num_available++;
my $branchitemrule = GetBranchItemRule( $item->{'homebranch'}, $item->{'itype'} );
my $policy_holdallowed = 1;
$item->{'holdallowed'} = $branchitemrule->{'holdallowed'};
if ( $branchitemrule->{'holdallowed'} == 0 ||
( $branchitemrule->{'holdallowed'} == 1 && $borrowerinfo->{'branchcode'} ne $item->{'homebranch'} ) ) {
$policy_holdallowed = 0;
}
if (IsAvailableForItemLevelRequest($itemnumber) and not $item->{cantreserve}) {
if ( not $policy_holdallowed and C4::Context->preference( 'AllowHoldPolicyOverride' ) ) {
$item->{override} = 1;
$num_override++;
} elsif ( $policy_holdallowed ) {
$item->{available} = 1;
$num_available++;
}
}
# If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
# FIXME: move this to a pm
my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'");
$sth2->execute($item->{ReservedForBorrowernumber},$item->{itemnumber});
while (my $wait_hashref = $sth2->fetchrow_hashref) {
$item->{waitingdate} = format_date($wait_hashref->{waitingdate});
}
push @{ $biblioitem->{itemloop} }, $item;
}
# If none of the conditions hold true, then neither override nor available is set and the item cannot be checked
# FIXME: move this to a pm
my $sth2 = $dbh->prepare("SELECT * FROM reserves WHERE borrowernumber=? AND itemnumber=? AND found='W'");
$sth2->execute($item->{ReservedForBorrowernumber},$item->{itemnumber});
while (my $wait_hashref = $sth2->fetchrow_hashref) {
$item->{waitingdate} = format_date($wait_hashref->{waitingdate});
if ( $num_override == scalar( @{ $biblioitem->{itemloop} } ) ) { # That is, if all items require an override
$template->param( override_required => 1 );
} elsif ( $num_available == 0 ) {
$template->param( none_available => 1 );
$template->param( warnings => 1 );
$biblioloopiter{warn} = 1;
$biblioloopiter{none_avail} = 1;
}
push @{ $biblioitem->{itemloop} }, $item;
}
if ( $num_override == scalar( @{ $biblioitem->{itemloop} } ) ) { # That is, if all items require an override
$template->param( override_required => 1 );
} elsif ( $num_available == 0 ) {
$template->param( none_available => 1 );
$template->param( warnings => 1 );
}
push @bibitemloop, $biblioitem;
}
# existingreserves building
my @reserveloop;
( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber);
foreach my $res ( sort { $a->{found} cmp $b->{found} } @$reserves ) {
my %reserve;
my @optionloop;
for ( my $i = 1 ; $i <= $totalcount ; $i++ ) {
push(
@optionloop,
{
num => $i,
selected => ( $i == $res->{priority} ),
}
);
}
my @branchloop;
foreach my $br ( keys %$branches ) {
my %abranch;
$abranch{'selected'} = ( $br eq $res->{'branchcode'} );
$abranch{'branch'} = $br;
$abranch{'branchname'} = $branches->{$br}->{'branchname'};
push( @branchloop, \%abranch );
push @bibitemloop, $biblioitem;
}
if ( ( $res->{'found'} eq 'W' ) ) {
my $item = $res->{'itemnumber'};
$item = GetBiblioFromItemNumber($item,undef);
$reserve{'wait'}= 1;
$reserve{'holdingbranch'}=$item->{'holdingbranch'};
$reserve{'biblionumber'}=$item->{'biblionumber'};
$reserve{'barcodenumber'} = $item->{'barcode'};
$reserve{'wbrcode'} = $res->{'branchcode'};
$reserve{'itemnumber'} = $res->{'itemnumber'};
$reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'};
if($reserve{'holdingbranch'} eq $reserve{'wbrcode'}){
$reserve{'atdestination'} = 1;
# existingreserves building
my @reserveloop;
( $count, $reserves ) = GetReservesFromBiblionumber($biblionumber);
foreach my $res ( sort { $a->{found} cmp $b->{found} } @$reserves ) {
my %reserve;
my @optionloop;
for ( my $i = 1 ; $i <= $totalcount ; $i++ ) {
push(
@optionloop,
{
num => $i,
selected => ( $i == $res->{priority} ),
}
);
}
# set found to 1 if reserve is waiting for patron pickup
$reserve{'found'} = 1 if $res->{'found'} eq 'W';
} elsif ($res->{priority} > 0) {
if (defined($res->{itemnumber})) {
my $item = GetItem($res->{itemnumber});
$reserve{'itemnumber'} = $res->{'itemnumber'};
my @branchloop;
foreach my $br ( keys %$branches ) {
my %abranch;
$abranch{'selected'} = ( $br eq $res->{'branchcode'} );
$abranch{'branch'} = $br;
$abranch{'branchname'} = $branches->{$br}->{'branchname'};
push( @branchloop, \%abranch );
}
if ( ( $res->{'found'} eq 'W' ) ) {
my $item = $res->{'itemnumber'};
$item = GetBiblioFromItemNumber($item,undef);
$reserve{'wait'}= 1;
$reserve{'holdingbranch'}=$item->{'holdingbranch'};
$reserve{'biblionumber'}=$item->{'biblionumber'};
$reserve{'barcodenumber'} = $item->{'barcode'};
$reserve{'item_level_hold'} = 1;
$reserve{'wbrcode'} = $res->{'branchcode'};
$reserve{'itemnumber'} = $res->{'itemnumber'};
$reserve{'wbrname'} = $branches->{$res->{'branchcode'}}->{'branchname'};
if($reserve{'holdingbranch'} eq $reserve{'wbrcode'}){
$reserve{'atdestination'} = 1;
}
# set found to 1 if reserve is waiting for patron pickup
$reserve{'found'} = 1 if $res->{'found'} eq 'W';
} elsif ($res->{priority} > 0) {
if (defined($res->{itemnumber})) {
my $item = GetItem($res->{itemnumber});
$reserve{'itemnumber'} = $res->{'itemnumber'};
$reserve{'barcodenumber'} = $item->{'barcode'};
$reserve{'item_level_hold'} = 1;
}
}
# get borrowers reserve info
my $reserveborrowerinfo = GetMemberDetails( $res->{'borrowernumber'}, 0);
$reserve{'date'} = format_date( $res->{'reservedate'} );
$reserve{'borrowernumber'} = $res->{'borrowernumber'};
$reserve{'biblionumber'} = $res->{'biblionumber'};
$reserve{'borrowernumber'} = $res->{'borrowernumber'};
$reserve{'firstname'} = $reserveborrowerinfo->{'firstname'};
$reserve{'surname'} = $reserveborrowerinfo->{'surname'};
$reserve{'notes'} = $res->{'reservenotes'};
$reserve{'wait'} =
( ( $res->{'found'} eq 'W' ) or ( $res->{'priority'} eq '0' ) );
$reserve{'constrainttypea'} = ( $res->{'constrainttype'} eq 'a' );
$reserve{'constrainttypeo'} = ( $res->{'constrainttype'} eq 'o' );
$reserve{'voldesc'} = $res->{'volumeddesc'};
$reserve{'ccode'} = $res->{'ccode'};
$reserve{'barcode'} = $res->{'barcode'};
$reserve{'priority'} = $res->{'priority'};
$reserve{'branchloop'} = \@branchloop;
$reserve{'optionloop'} = \@optionloop;
push( @reserveloop, \%reserve );
}
# get borrowers reserve info
my $reserveborrowerinfo = GetMemberDetails( $res->{'borrowernumber'}, 0);
$reserve{'date'} = format_date( $res->{'reservedate'} );
$reserve{'borrowernumber'} = $res->{'borrowernumber'};
$reserve{'biblionumber'} = $res->{'biblionumber'};
$reserve{'borrowernumber'} = $res->{'borrowernumber'};
$reserve{'firstname'} = $reserveborrowerinfo->{'firstname'};
$reserve{'surname'} = $reserveborrowerinfo->{'surname'};
$reserve{'notes'} = $res->{'reservenotes'};
$reserve{'wait'} =
( ( $res->{'found'} eq 'W' ) or ( $res->{'priority'} eq '0' ) );
$reserve{'constrainttypea'} = ( $res->{'constrainttype'} eq 'a' );
$reserve{'constrainttypeo'} = ( $res->{'constrainttype'} eq 'o' );
$reserve{'voldesc'} = $res->{'volumeddesc'};
$reserve{'ccode'} = $res->{'ccode'};
$reserve{'barcode'} = $res->{'barcode'};
$reserve{'priority'} = $res->{'priority'};
$reserve{'branchloop'} = \@branchloop;
$reserve{'optionloop'} = \@optionloop;
push( @reserveloop, \%reserve );
}
# get the time for the form name...
my $time = time();
$template->param(
CGIbranch => $CGIbranch,
my $default = C4::Context->userenv->{branch};
my @values;
my %label_of;
time => $time,
fixedRank => $fixedRank,
);
# display infos
$template->param(
optionloop => \@optionloop,
bibitemloop => \@bibitemloop,
date => $date,
biblionumber => $biblionumber,
findborrower => $findborrower,
cardnumber => $cardnumber,
CGIselectborrower => $CGIselectborrower,
title => $dat->{title},
author => $dat->{author},
holdsview => 1,
borrower_branchname => $branches->{$borrowerinfo->{'branchcode'}}->{'branchname'},
borrower_branchcode => $borrowerinfo->{'branchcode'},
);
$biblioloopiter{biblionumber} = $biblionumber;
$biblioloopiter{title} = $dat->{title};
$biblioloopiter{rank} = $fixedRank;
$biblioloopiter{reserveloop} = \@reserveloop;
if (@reserveloop) {
$template->param( reserveloop => \@reserveloop );
}
foreach my $branchcode (sort keys %{$branches} ) {
push @values, $branchcode;
$label_of{$branchcode} = $branches->{$branchcode}->{branchname};
push @biblioloop, \%biblioloopiter;
}
my $CGIbranch = CGI::scrolling_list(
-name => 'pickup',
-id => 'pickup',
-values => \@values,
-default => $default,
-labels => \%label_of,
-size => 1,
-multiple => 0,
);
# get the time for the form name...
my $time = time();
$template->param(
CGIbranch => $CGIbranch,
reserveloop => \@reserveloop,
time => $time,
fixedRank => $fixedRank,
);
# display infos
$template->param(
optionloop => \@optionloop,
bibitemloop => \@bibitemloop,
date => $date,
biblionumber => $biblionumber,
findborrower => $findborrower,
cardnumber => $cardnumber,
CGIselectborrower => $CGIselectborrower,
title => $dat->{title},
author => $dat->{author},
holdsview => 1,
borrower_branchname => $branches->{$borrowerinfo->{'branchcode'}}->{'branchname'},
borrower_branchcode => $borrowerinfo->{'branchcode'},
);
$template->param( biblioloop => \@biblioloop );
$template->param( biblionumbers => $biblionumbers );
if ($multihold) {
$template->param( multi_hold => 1 );
}
# printout the page
output_html_with_http_headers $input, $cookie, $template->output;

97
virtualshelves/addbybiblionumber.pl

@ -67,7 +67,13 @@ use CGI::Carp qw/fatalsToBrowser/;
use warnings;
my $query = new CGI;
# If set, then single item case.
my $biblionumber = $query->param('biblionumber');
# If set, then multiple item case.
my $biblionumbers = $query->param('biblionumbers');
my $shelfnumber = $query->param('shelfnumber');
my $newvirtualshelf = $query->param('newvirtualshelf');
my $category = $query->param('category');
@ -83,50 +89,79 @@ my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
}
);
my @biblionumbers;
if ($biblionumbers) {
@biblionumbers = split '/', $biblionumbers;
} else {
@biblionumbers = ($biblionumber);
}
$shelfnumber = AddShelf( $newvirtualshelf, $loggedinuser, $category, $sortfield )
if $newvirtualshelf;
if ( $shelfnumber || ( $shelfnumber == -1 ) ) { # the shelf already exist.
AddToShelfFromBiblio( $biblionumber, $shelfnumber );
foreach my $biblionumber (@biblionumbers) {
AddToShelfFromBiblio( $biblionumber, $shelfnumber );
}
print
"Content-Type: text/html\n\n<html><body onload=\"window.close()\"></body></html>";
exit;
}
else { # this shelf doesn't already exist.
my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
my $limit = 10;
my ($shelflist) = GetRecentShelves(1, $limit, $loggedinuser);
my $limit = 10;
my ($shelflist) = GetRecentShelves(1, $limit, $loggedinuser);
my @shelvesloop;
my %shelvesloop;
for my $shelf ( @{ $shelflist->[0] } ) {
push( @shelvesloop, $shelf->{shelfnumber} );
$shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
}
# then open shelves...
my ($shelflist) = GetRecentShelves(3, $limit, undef);
$shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
}
# then open shelves...
my ($shelflist) = GetRecentShelves(3, $limit, undef);
for my $shelf ( @{ $shelflist->[0] } ) {
push( @shelvesloop, $shelf->{shelfnumber} );
$shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
}
if(@shelvesloop gt 0){
my $CGIvirtualshelves = CGI::scrolling_list(
-name => 'shelfnumber',
-values => \@shelvesloop,
-labels => \%shelvesloop,
-size => 1,
-tabindex => '',
-multiple => 0
);
$template->param(
CGIvirtualshelves => $CGIvirtualshelves,
);
}
$template->param(
biblionumber => $biblionumber,
title => $biblios[0]->{'title'},
author => $biblios[0]->{'author'},
);
$shelvesloop{$shelf->{shelfnumber}} = $shelf->{shelfname};
}
if(@shelvesloop gt 0){
my $CGIvirtualshelves = CGI::scrolling_list
(
-name => 'shelfnumber',
-values => \@shelvesloop,
-labels => \%shelvesloop,
-size => 1,
-tabindex => '',
-multiple => 0
);
$template->param
(
CGIvirtualshelves => $CGIvirtualshelves,
);
}
unless ($biblionumbers) {
my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
$template->param
(
biblionumber => $biblionumber,
title => $biblios[0]->{'title'},
author => $biblios[0]->{'author'},
);
} else {
my @biblioloop = ();
foreach my $biblionumber (@biblionumbers) {
my ( $bibliocount, @biblios ) = GetBiblio($biblionumber);
my %biblioiter = (
title=>$biblios[0]->{'title'},
author=>$biblios[0]->{'author'}
);
push @biblioloop, \%biblioiter;
}
$template->param
(
biblioloop => \@biblioloop,
biblionumbers => $biblionumbers
);
}
output_html_with_http_headers $query, $cookie, $template->output;
}

Loading…
Cancel
Save