Merge remote-tracking branch 'eg-working/collab/berick/lp_888239_prevent_post-capture...
authorMike Rylander <mrylander@gmail.com>
Tue, 15 Nov 2011 16:48:15 +0000 (11:48 -0500)
committerMike Rylander <mrylander@gmail.com>
Tue, 15 Nov 2011 16:48:15 +0000 (11:48 -0500)
Open-ILS/src/extras/ils_events.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader/Account.pm
Open-ILS/src/templates/opac/myopac/holds.tt2
Open-ILS/src/templates/opac/myopac/holds/edit.tt2

index 0297eff..0a8b7a8 100644 (file)
        <event code='1714' textcode='HIGH_LEVEL_HOLD_HAS_NO_COPIES'>
                <desc xml:lang="en-US">A hold request at a higher level than copy has been attempted, but there are no copies that belonging to the higher-level unit.</desc>
        </event>
+       <event code='1715' textcode='HOLD_SUSPEND_AFTER_CAPTURE'>
+               <desc xml:lang="en-US">Attempt to suspend a hold after it has been captured.</desc>
+       </event>
 
 
        <event code='2000' textcode='BAD_PARAMS'>
index 9ed7f49..3719afc 100644 (file)
@@ -867,6 +867,7 @@ sub batch_update_hold {
 
 sub update_hold_impl {
     my($self, $e, $hold, $values) = @_;
+    my $hold_status;
 
     unless($hold) {
         $hold = $e->retrieve_action_hold_request($values->{id})
@@ -913,15 +914,28 @@ sub update_hold_impl {
                return $e->die_event unless $e->allowed('UPDATE_HOLD_REQUEST_TIME', $hold->pickup_lib);
        }
 
+
+    # --------------------------------------------------------------
+    # Disallow hold suspencion if the hold is already captured.
+    # --------------------------------------------------------------
+    if ($U->is_true($hold->frozen) and not $U->is_true($orig_hold->frozen)) {
+        $hold_status = _hold_status($e, $hold);
+        if ($hold_status > 2) { # hold is captured
+            $logger->info("bypassing hold freeze on captured hold");
+            return OpenILS::Event->new('HOLD_SUSPEND_AFTER_CAPTURE');
+        }
+    }
+
+
     # --------------------------------------------------------------
     # if the hold is on the holds shelf or in transit and the pickup 
     # lib changes we need to create a new transit.
     # --------------------------------------------------------------
     if($orig_hold->pickup_lib ne $hold->pickup_lib) {
 
-        my $status = _hold_status($e, $hold);
+        $hold_status = _hold_status($e, $hold) unless $hold_status;
 
-        if($status == 3) { # in transit
+        if($hold_status == 3) { # in transit
 
             return $e->die_event unless $e->allowed('UPDATE_PICKUP_LIB_FROM_TRANSIT', $orig_hold->pickup_lib);
             return $e->die_event unless $e->allowed('UPDATE_PICKUP_LIB_FROM_TRANSIT', $hold->pickup_lib);
@@ -937,7 +951,7 @@ sub update_hold_impl {
             $transit->dest($hold->pickup_lib);
             $e->update_action_hold_transit_copy($transit) or return $e->die_event;
 
-        } elsif($status == 4) { # on holds shelf
+        } elsif($hold_status == 4) { # on holds shelf
 
             return $e->die_event unless $e->allowed('UPDATE_PICKUP_LIB_FROM_HOLDS_SHELF', $orig_hold->pickup_lib);
             return $e->die_event unless $e->allowed('UPDATE_PICKUP_LIB_FROM_HOLDS_SHELF', $hold->pickup_lib);
index fdbb3e3..21c08ab 100644 (file)
@@ -467,7 +467,10 @@ sub handle_hold_update {
             push(@$vlist, $vals);
         }
 
-        $circ->request('open-ils.circ.hold.update.batch.atomic', $e->authtoken, undef, $vlist)->gather(1);
+        my $resp = $circ->request('open-ils.circ.hold.update.batch.atomic', $e->authtoken, undef, $vlist)->gather(1);
+        $self->ctx->{hold_suspend_post_capture} = 1 if 
+            grep {$U->event_equals($_, 'HOLD_SUSPEND_AFTER_CAPTURE')} @$resp;
+
     } elsif ($action eq 'edit') {
 
         my @vals = map {
index 279f53c..56327ee 100644 (file)
                         alt="Holds Help"
                         src="[% ctx.media_prefix %]/images/question-mark.png" /></a>
                 </td>
+                <td style="padding-left:5px;" class='error'>
+                    [%  IF ctx.hold_suspend_post_capture;
+                            l('One or more holds could not be suspended because<br/>the item is at (or en route to) the pickup library.');
+                        END;
+                    %]
+                </td>
                 <td align="right">
                     [% l("Show") %] &nbsp; &nbsp;
                     [% IF CGI.param("available") %]
index 7ba1528..fc2d3d9 100644 (file)
@@ -46,6 +46,9 @@
                                 name='pickup_lib' value=ahr.pickup_lib %]
                         </td>
                     </tr>
+                    [% IF hold.hold.status < 3 %]
+                    [%# The following actions cannot be performed on holds that 
+                        have already been captured... %]
                     <tr>
                         <th>
                             [% l('Cancel unless filled by') %]
                             <em>[% l('Enter date in MM/DD/YYYY format') %]</em>
                         </td>
                     </tr>
+                    [% END %]
                     <tr>
                         <td colspan="2" class="hold-editor-controls">
-                            <input type="submit"
-                                value="[% l('Submit') %]"
-                                class="opac-button" />
-                            <input type="reset"
-                                value="[% l('Cancel') %]"
-                                class="opac-button" />
+                            <a href="[% ctx.opac_root %]/myopac/holds"><button 
+                                class="opac-button">[% l('Go Back') %]</button></a>
+                            <input type="submit" value="[% l('Submit') %]" class="opac-button" />
                         </td>
                     </tr>
                 </table>