From 5981733f695d4b2ac8c17e5c229184b2f77fa88e Mon Sep 17 00:00:00 2001
From: Bill Erickson <berick@esilibrary.com>
Date: Tue, 6 Aug 2013 13:52:24 -0400
Subject: [PATCH] LP1207396 pending patron reg show requestor

Show a link to the requesting user, when present, for pending patrons in
the staff client patron registration form.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Dan Wells <dbw2@calvin.edu>
---
 Open-ILS/src/templates/actor/user/register.tt2     |  6 ++++
 Open-ILS/web/css/skin/default/register.css         |  1 +
 Open-ILS/web/js/dojo/openils/actor/nls/register.js |  3 +-
 Open-ILS/web/js/ui/default/actor/user/register.js  | 34 ++++++++++++++++++++++
 4 files changed, 43 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/src/templates/actor/user/register.tt2 b/Open-ILS/src/templates/actor/user/register.tt2
index e17328ecb5..95be9629b5 100644
--- a/Open-ILS/src/templates/actor/user/register.tt2
+++ b/Open-ILS/src/templates/actor/user/register.tt2
@@ -22,8 +22,14 @@
         <a href='javascript:uEditToggleRequired(2);' id='uedit-show-suggested'>[% l('Show Suggested Fields') %]</a><br id='uedit-show-suggested-br'/>
         <a href='javascript:uEditToggleRequired(0);' id='uedit-show-all' class='hidden'>[% l('Show All Fields') %]</a>
     </div>
+
+    <!-- link to requesting user account for pending users -->
+    <div class='hidden' id='uedit-requesting-user-div'>
+        <a href='javascript:;' id='uedit-requesting-user'></a>
+    </div>
 </div>
 
+
 <!-- context help widget -->
 <a class='hidden' id='uedit-help-template'><img src='/opac/images/advancedsearch-icon.png'></img></a>
 <fieldset id='uedit-help-div' class='hidden'>
diff --git a/Open-ILS/web/css/skin/default/register.css b/Open-ILS/web/css/skin/default/register.css
index 582975b042..3ea73096b1 100644
--- a/Open-ILS/web/css/skin/default/register.css
+++ b/Open-ILS/web/css/skin/default/register.css
@@ -106,4 +106,5 @@
     margin-bottom:-5px;
 }
 
+#uedit-requesting-user-div { margin: 8px; }
 
diff --git a/Open-ILS/web/js/dojo/openils/actor/nls/register.js b/Open-ILS/web/js/dojo/openils/actor/nls/register.js
index eefeb9412a..f7d13b6aad 100644
--- a/Open-ILS/web/js/dojo/openils/actor/nls/register.js
+++ b/Open-ILS/web/js/dojo/openils/actor/nls/register.js
@@ -39,5 +39,6 @@
     "INVALIDATE": "Invalidate",
     "HOLD_NOTIFY_PHONE": "Phone: ",
     "HOLD_NOTIFY_EMAIL": "Email: ",
-    "HOLD_NOTIFY_SMS": "SMS: "
+    "HOLD_NOTIFY_SMS": "SMS: ",
+    "REQUESTING_USER" : "Account requested by ${0} ${1}"
 }
diff --git a/Open-ILS/web/js/ui/default/actor/user/register.js b/Open-ILS/web/js/ui/default/actor/user/register.js
index 7280a10364..aabdc3c203 100644
--- a/Open-ILS/web/js/ui/default/actor/user/register.js
+++ b/Open-ILS/web/js/ui/default/actor/user/register.js
@@ -509,6 +509,40 @@ function uEditLoadStageUser(stageUname) {
     if(!stageUser) 
         return patron;
 
+    /* if we know who requested this pending account, show the requestor's
+     * name and create a link to open the requestor in a new tab */
+    if (stageUser.requesting_usr()) {
+        fieldmapper.standardRequest(
+            ['open-ils.actor', 'open-ils.actor.user.retrieve.parts'],
+            {   params : [
+                    openils.User.authtoken, 
+                    stageUser.requesting_usr(), 
+                    ['first_given_name', 'family_name']
+                ],
+                oncomplete : function(r) {
+                    var res = openils.Util.readResponse(r);
+                    if (!res) return;
+
+                    var link = dojo.byId('uedit-requesting-user');
+                    link.innerHTML = dojo.string.substitute(
+                        localeStrings.REQUESTING_USER, res);
+                    openils.Util.show(link.parentNode);
+
+                    link.onclick = function() {
+                        window.xulG.new_patron_tab(                
+                            {   'tab_name' : '' }, // tab name is set on draw
+                            {   'id' : stageUser.requesting_usr(),
+                                'url_prefix' : xulG.url_prefix,    
+                                'new_tab' : xulG.new_tab,          
+                                'set_tab' : xulG.set_tab           
+                            }                                      
+                        ); 
+                    };
+                }
+            }
+        );
+    }
+
     // copy the data into our new user object
     for(var key in fieldmapper.IDL.fmclasses.stgu.field_map) {
         if(fieldmapper.IDL.fmclasses.au.field_map[key] && !fieldmapper.IDL.fmclasses.stgu.field_map[key].virtual) {
-- 
2.11.0