[Koha-patches] [PATCH] Bug 3146: OPAC Holds broken in Single Branch Mode.
Ryan Higgins
rch at liblime.com
Sun May 31 01:03:29 CEST 2009
Forces branch definition in multi-hold processing.
Also (somewhat arbitrarily) limits the number of holds that can be simultaneously processed
to either the maxReserves syspref or 36 if that's not defined.
---
.../opac-tmpl/prog/en/modules/opac-reserve.tmpl | 5 ++-
opac/opac-reserve.pl | 43 ++++++--------------
2 files changed, 17 insertions(+), 31 deletions(-)
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tmpl b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tmpl
index 4e015a2..d05acf5 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tmpl
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-reserve.tmpl
@@ -110,6 +110,7 @@
// Find the items with the 'Hold' box checked
var badBib = null;
+ var i = 0;
$(".confirmjs:checked").each(function() {
var biblioNum = $(this).val();
biblionumbers += biblioNum + "/";
@@ -133,7 +134,9 @@
if (branchSel.size() > 0) {
selections += $(branchSel).val();
}
- selections += "/";
+ if(++i < $(".confirmjs:checked").length){
+ selections += "/";
+ }
return true;
});
diff --git a/opac/opac-reserve.pl b/opac/opac-reserve.pl
index 4395f38..ea39c5f 100755
--- a/opac/opac-reserve.pl
+++ b/opac/opac-reserve.pl
@@ -33,6 +33,7 @@ use C4::Debug;
# use Data::Dumper;
my $MAXIMUM_NUMBER_OF_RESERVES = C4::Context->preference("maxreserves");
+my $MAX_SIMULTANEOUS_RESERVES = ($MAXIMUM_NUMBER_OF_RESERVES > 36) ? 36 : $MAXIMUM_NUMBER_OF_RESERVES;
my $query = new CGI;
my ( $template, $borrowernumber, $cookie ) = get_template_and_user(
@@ -92,20 +93,12 @@ my $branch = $query->param('branch') || C4::Context->userenv->{branch} || '' ;
($branches->{$branch}) or $branch = ""; # Confirm branch is real
$template->param( branch => $branch );
+my $singleBranchMode = C4::Context->preference('singleBranchMode');
+
# make branch selection options...
my $CGIbranchloop = GetBranchesLoop($branch);
$template->param( CGIbranch => $CGIbranchloop );
-#Debug
-#output_html_with_http_headers($query,$cookie,"<html><head></head><body> @biblionumbers </body></html>\n");
-#exit;
-#my %bibdata;
-#my $rank;
-#my $biblionumber;
-#my $bibdata;
-#my %itemhash;
-#my $forloan;
-
#
#
# Build hashes of the requested biblio(item)s and items.
@@ -155,7 +148,6 @@ if ( $query->param('place_reserve') ) {
# List is composed of alternating biblio/item/branch
my $selectedItems = $query->param('selecteditems');
-
if ($query->param('reserve_mode') eq 'single') {
# This indicates non-JavaScript mode, so there was
# only a single biblio number selected.
@@ -165,15 +157,15 @@ if ( $query->param('place_reserve') ) {
$item = '';
}
my $branch = $query->param('branch');
- $selectedItems = "$bib/$item/$branch/";
+ $selectedItems = "$bib/$item/$branch";
}
-
- my @selectedItems = split /\//, $selectedItems;
+ my @selectedItems = split(/\//, $selectedItems, $MAX_SIMULTANEOUS_RESERVES);
+ # split's limit param forces trailing empty strings to be included in array.
# Make sure there is a biblionum/itemnum/branch triplet for each item.
- # The itemnum can be 'any', meaning next available.
- my $selectionCount = @selectedItems;
- if (($selectionCount == 0) || (($selectionCount % 3) != 0)) {
+ # The itemnum can be '', meaning next available.
+ my $selectionCount = scalar @selectedItems;
+ if (($selectionCount == 0) || ($selectionCount % 3)) {
$template->param(message=>1, bad_data=>1);
&get_out($query, $cookie, $template->output);
}
@@ -181,12 +173,7 @@ if ( $query->param('place_reserve') ) {
while (@selectedItems) {
my $biblioNum = shift(@selectedItems);
my $itemNum = shift(@selectedItems);
- my $branch = shift(@selectedItems); # i.e., branch code, not name
-
- my $singleBranchMode = $template->param('singleBranchMode');
- if ($singleBranchMode) {
- $branch = $borr->{'branchcode'};
- }
+ my $branch = ($singleBranchMode) ? $borr->{'branchcode'} : shift(@selectedItems);
my $biblioData = $biblioDataHash{$biblioNum};
my $found;
@@ -454,13 +441,9 @@ if ( $numBibsAvailable == 0 ) {
$template->param( none_available => 1, message => 1 );
}
-my $itemTableColspan = 5;
-if (!$template->param('OPACItemHolds')) {
- $itemTableColspan--;
-}
-if ($template->param('singleBranchMode')) {
- $itemTableColspan--;
-}
+my $itemTableColspan = ($template->param('OPACItemHolds')) ? 4 : 5 ;
+$singleBranchMode and $itemTableColspan--;
+
$template->param(itemtable_colspan => $itemTableColspan);
# display infos
--
1.5.6.2
More information about the Koha-patches
mailing list