From 0125e93151fb32861c73ba6e03af71726d2ac3c3 Mon Sep 17 00:00:00 2001
From: Owen Leonard <oleonard@myacpl.org>
Date: Tue, 20 Nov 2012 11:40:51 -0500
Subject: [PATCH] Bug 9115 [3.6.x] basket window should close automatically
 when placing a hold
Content-Type: text/plain; charset="utf-8"

If you choose to place a hold from the Cart pop-up, the entire
holds process (possibly including login) takes place in the cart
window. Upon completion of the operation you're left with a second
window which has lost its context as the Cart.

This patch revises the hold process so that when you click the
hold link in the cart the operation is moved to the main window
and the Cart window closes.

Since the holdSel() function doesn't require interaction with
template variables I have moved it to basket.js along with the
described changes.

To test, put items in your Cart and open it. Select items to
place on hold and click the "Place hold" link. The cart
should close, and the items you selected should appear on the
place hold screen in the main window.
---
 koha-tmpl/opac-tmpl/prog/en/js/basket.js           |   10 ++++++++++
 koha-tmpl/opac-tmpl/prog/en/modules/opac-basket.tt |   10 ----------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/koha-tmpl/opac-tmpl/prog/en/js/basket.js b/koha-tmpl/opac-tmpl/prog/en/js/basket.js
index a3675ad..63743bb 100644
--- a/koha-tmpl/opac-tmpl/prog/en/js/basket.js
+++ b/koha-tmpl/opac-tmpl/prog/en/js/basket.js
@@ -381,6 +381,16 @@ function showLess() {
     document.location = loc;
 }
 
+function holdSel() {
+    var items = document.getElementById('records').value;
+    if (items) {
+        parent.opener.document.location = "/cgi-bin/koha/opac-reserve.pl?biblionumbers=" + items;
+        window.close();
+    } else {
+        alert(MSG_NO_RECORD_SELECTED);
+    }
+}
+
 function updateBasket(updated_value,target) {
 	if(target){
 	target.$('#basketcount').html("<span>"+updated_value+"</span>");
diff --git a/koha-tmpl/opac-tmpl/prog/en/modules/opac-basket.tt b/koha-tmpl/opac-tmpl/prog/en/modules/opac-basket.tt
index 35fe06a..0c3811a 100644
--- a/koha-tmpl/opac-tmpl/prog/en/modules/opac-basket.tt
+++ b/koha-tmpl/opac-tmpl/prog/en/modules/opac-basket.tt
@@ -100,16 +100,6 @@ function tagAdded() {
           });
 [% END %][% END %][% END %]
 	});
-[% IF ( opacuserlogin ) %][% IF ( RequestOnOpac ) %]
-    function holdSel() {
-        var items = document.getElementById('records').value;
-        if (items) {
-            document.location = "/cgi-bin/koha/opac-reserve.pl?biblionumbers=" + items;
-        } else {
-            alert(MSG_NO_RECORD_SELECTED);
-        }
-    }
-[% END %][% END %]
 	//]]>
 	</script>
 	[% END %]
-- 
1.7.9.5