Staff can now place title-type holds for patrons
authorLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 11 Jul 2011 21:43:51 +0000 (17:43 -0400)
committerLebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Mon, 11 Jul 2011 21:43:51 +0000 (17:43 -0400)
Still need to put in copy, volume and issuance (and parts? maybe later) -type
holds.  Still need to deal with overridable events.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/web/css/skin/default/opac/style.css
Open-ILS/web/js/ui/default/opac/staff.js
Open-ILS/web/templates/default/opac/parts/place_hold.tt2

index efaeb28..371ce14 100644 (file)
@@ -366,10 +366,28 @@ sub load_place_hold {
 
     $ctx->{marc_xml} = XML::LibXML->new->parse_string($ctx->{record}->marc);
 
-    if(my $pickup_lib = $cgi->param('pickup_lib')) {
+    if (my $pickup_lib = $cgi->param('pickup_lib')) {
+        my $requestor = $e->requestor->id;
+        my $usr; 
+
+        if ((not $ctx->{"is_staff"}) or
+            ($cgi->param("hold_usr_is_requestor"))) {
+            $usr = $requestor;
+        } else {
+            my $actor = create OpenSRF::AppSession("open-ils.actor");
+            $usr = $actor->request(
+                "open-ils.actor.user.retrieve_id_by_barcode_or_username",
+                $e->authtoken, $cgi->param("hold_usr")
+            )->gather(1);
+
+            if (defined $U->event_code($usr)) {
+                $ctx->{hold_failed} = 1;
+                $ctx->{hold_failed_event} = $usr;
+            }
+        }
 
         my $args = {
-            patronid => $e->requestor->id,
+            patronid => $usr,
             titleid => $ctx->{hold_target}, # XXX
             pickup_lib => $pickup_lib,
             depth => 0, # XXX
@@ -385,8 +403,8 @@ sub load_place_hold {
             my $hold = Fieldmapper::action::hold_request->new;
 
             $hold->pickup_lib($pickup_lib);
-            $hold->requestor($e->requestor->id);
-            $hold->usr($e->requestor->id); # XXX staff
+            $hold->requestor($requestor);
+            $hold->usr($usr);
             $hold->target($ctx->{hold_target});
             $hold->hold_type($ctx->{hold_type});
             # frozen, expired, etc..
index 0e7ffda..cf2088b 100644 (file)
@@ -1002,3 +1002,4 @@ a.dash-link:hover { text-decoration: underline !important; }
 
 .invisible { visibility: hidden; }
 .rdetail-extras-summary { margin: 10px; }
+.staff-hold { background-color: #eee; }
index abb8ce8..533258c 100644 (file)
@@ -14,6 +14,10 @@ function runEvt(scope, name) {
         for(var i in evt) {evt[i].apply(evt[i], args);}
     } 
 }
+function staff_hold_nicety(thing) {
+    document.getElementById("hold_usr_input").disabled =
+        Boolean(Number(thing.value));
+}
 window.onload = function() {
     // record details page events
     var rec = location.href.match(/\/opac\/record\/(\d+)/);
index 8f56aa5..3e37244 100644 (file)
@@ -3,39 +3,6 @@
     PROCESS get_marc_attrs args=attrs;
 %]
 <div>
-    <div id='xulholds_box' class='hide_me canvas' style='margin-top: 6px;'>
-        <!-- XXX TODO staff will need this to work ("advanced" hold placement)
-        later -->
-        <center>
-            <table class='data_grid' style='margin-top: 20px;'>
-                <tbody>
-                    <tr>
-                        <td>[% l("Enter recipient barcode") %]:</td>
-                        <td>
-                            <input type='text' id='xul_recipient_barcode' />
-                        </td>
-                        <td>
-                            <input type='submit' value='[% l("Submit") %]'
-                                id='xul_recipient_barcode_submit' />
-                        </td>
-                        <td>
-                            <input type='submit' value='[% l("Cancel") %]' />
-                        </td>
-                        <td>
-                            <input type='submit'
-                                value='[% l("Place hold for my account") %]'
-                                id='xul_recipient_me' />
-                        </td>
-                    </tr>
-                </tbody>
-            </table>
-        </center>
-    </div>
-    <div id='check_holds_box' class='hide_me canvas' 
-        style='margin-top: 6px; width: 100%; text-align: center'>
-        <br/><br/><br/>
-        <b>[% l("Checking for possibility of hold fulfillment...") %]</b>
-    </div>
     <div id='holds_box' class='canvas' style='margin-top: 6px;'>
         [% IF ctx.hold_success %]
         <div><big><strong>[% l("Hold was successfully placed"); %]</strong></big></div>
             <input type="hidden" name="redirect_to"
                 value="[% new_redirect_to | html %]" />
             <h1>Place Hold</h1>
+            [% IF ctx.is_staff %]
+            <p class="staff-hold">
+                <input type="radio" id="hold_usr_is_requestor_not"
+                    onchange="staff_hold_nicety(this);"
+                    name="hold_usr_is_requestor" value="0" />
+                <label for="hold_usr_is_requestor_not">
+                    [% l("Place hold for patron by barcode:") %]
+                </label>
+                <input type="text" name="hold_usr" id="hold_usr_input" /><br />
+
+                <input type="radio" id="hold_usr_is_requestor"
+                    onchange="staff_hold_nicety(this);"
+                    name="hold_usr_is_requestor" value="1" />
+                <label for="hold_usr_is_requestor">
+                    [% l("Place this hold for me ([_1] [_2])",
+                    ctx.user.first_given_name, ctx.user.family_name) %]
+                </label>
+            </p>
+            [% END %]
             <p>
                 [% | l(attrs.title, ctx.get_aou(ctx.default_pickup_lib).name) %]
                 You would like to place a hold on <strong><q>[_1]</q></strong> to be picked up at [_2].