show requestor workstation on reset entries hold tab user/lew/hold_reset_reason_entries
authorLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Wed, 10 May 2023 16:21:28 +0000 (12:21 -0400)
committerLlewellyn Marshall <llewellyn.marshall@ncdcr.gov>
Thu, 11 May 2023 13:59:02 +0000 (09:59 -0400)
additional notes for marked, damaged, and discarded hold copies

change default reset reason & note in holds app _reset_hold function.

signed-off-by: Llewellyn Marshall <llewellyn.marshall@ncdcr.gov>

Open-ILS/src/perlmods/lib/OpenILS/Application/Circ.pm
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
Open-ILS/src/templates/staff/circ/share/t_hold_details.tt2
Open-ILS/web/js/ui/default/staff/circ/services/holds.js

index b8aba47..cea8427 100644 (file)
@@ -1433,7 +1433,7 @@ sub mark_item {
     }
 
     $logger->debug("resetting holds that target the marked copy");
-    OpenILS::Application::Circ::Holds->_reset_hold($e->requestor, $_) for @$holds;
+    OpenILS::Application::Circ::Holds->_reset_hold($e->requestor, $_,OILS_HOLD_UPDATED) for @$holds;
 
     return 1;
 }
@@ -1625,7 +1625,7 @@ sub mark_item_missing_pieces {
     );
 
     $logger->debug("resetting holds that target the marked copy");
-    OpenILS::Application::Circ::Holds->_reset_hold($e2->requestor, $_) for @$holds;
+    OpenILS::Application::Circ::Holds->_reset_hold($e2->requestor, $_, OILS_HOLD_UPDATED) for @$holds;
 
     
     if (! $e2->commit) {
index 2240083..d5739a2 100644 (file)
@@ -1399,7 +1399,7 @@ sub update_hold_impl {
 
     # a change to mint-condition changes the set of potential copies, so retarget the hold;
     if($U->is_true($hold->mint_condition) and !$U->is_true($orig_hold->mint_condition)) {
-        _reset_hold($self, $e->requestor, $hold)
+        _reset_hold($self, $e->requestor, $hold, OILS_HOLD_UPDATED, "Item quality was changed.");
     } elsif($need_retarget && !defined $hold->capture_time()) { # If needed, retarget the hold due to changes        
         $U->simplereq('open-ils.hold-targeter', 
             'open-ils.hold-targeter.target', {hold => $hold->id});
@@ -2247,7 +2247,7 @@ sub reset_hold {
     return $evt if $evt;
     ($reqr, $evt) = $U->checksesperm($auth, 'UPDATE_HOLD');
     return $evt if $evt;
-    $evt = _reset_hold($self, $reqr, $hold);
+    $evt = _reset_hold($self, $reqr, $hold, OILS_HOLD_MANUAL_RESET);
     return $evt if $evt;
     return 1;
 }
@@ -2340,47 +2340,57 @@ sub reset_hold_batch {
 
 
 sub _reset_hold {
-    my ($self, $reqr, $hold) = @_;
+    my ($self, $reqr, $hold, $reset_reason, $reset_note) = @_;
 
     my $e = new_editor(xact =>1, requestor => $reqr);
     my $hid = $hold->id;
     $logger->info("reseting hold ".$hid." requestor was ".$reqr->usrname." (ID ".$reqr->id.")");
-    my $note_body = "";
-    if( $hold->capture_time and $hold->current_copy ) {
-
+    $reset_reason = (defined $reset_reason) ? $reset_reason : OILS_HOLD_MANUAL_RESET;
+    $reset_note = (defined $reset_note) ? $reset_note : "";
+    if($hold->current_copy){
         my $copy = $e->retrieve_asset_copy($hold->current_copy)
-            or return $e->die_event;
-
-        if( $copy->status == OILS_COPY_STATUS_ON_HOLDS_SHELF ) {
-            $logger->info("setting copy to status 'reshelving' on hold retarget");
-            $note_body.=" set copy to status 'reshelving'.";
-            $copy->status(OILS_COPY_STATUS_RESHELVING);
-            $copy->editor($e->requestor->id);
-            $copy->edit_date('now');
-            $e->update_asset_copy($copy) or return $e->die_event;
-
-        } elsif( $copy->status == OILS_COPY_STATUS_IN_TRANSIT ) {
-
-            $logger->warn("! reseting hold [$hid] that is in transit");
-            my $transid = $e->search_action_hold_transit_copy({hold=>$hold->id,cancel_time=>undef},{idlist=>1})->[0];
-
-            if( $transid ) {
-                my $trans = $e->retrieve_action_transit_copy($transid);
-                if( $trans ) {
-                    $logger->info("Aborting transit [$transid] on hold [$hid] reset...");
-                    my $evt = OpenILS::Application::Circ::Transit::__abort_transit($e, $trans, $copy, 1, 1);
-                    $logger->info("Transit abort completed with result $evt");
-                    $note_body.=" Transit abort completed with result $evt.";
-                    unless ("$evt" eq 1) {
-                        $e->rollback;
-                        return $evt;
+            or return $e->die_event; 
+        if( $hold->capture_time) {
+            if( $copy->status == OILS_COPY_STATUS_ON_HOLDS_SHELF ) {
+                $logger->info("setting copy to status 'reshelving' on hold retarget");
+                $reset_note.=" set copy to status 'reshelving'.";
+                $copy->status(OILS_COPY_STATUS_RESHELVING);
+                $copy->editor($e->requestor->id);
+                $copy->edit_date('now');
+                $e->update_asset_copy($copy) or return $e->die_event;
+
+            } elsif( $copy->status == OILS_COPY_STATUS_IN_TRANSIT ) {
+
+                $logger->warn("! reseting hold [$hid] that is in transit");
+                my $transid = $e->search_action_hold_transit_copy({hold=>$hold->id,cancel_time=>undef},{idlist=>1})->[0];
+
+                if( $transid ) {
+                    my $trans = $e->retrieve_action_transit_copy($transid);
+                    if( $trans ) {
+                        $logger->info("Aborting transit [$transid] on hold [$hid] reset...");
+                        my $evt = OpenILS::Application::Circ::Transit::__abort_transit($e, $trans, $copy, 1, 1);
+                        $logger->info("Transit abort completed with result $evt");
+                        $reset_note.=" Transit abort completed with result $evt.";
+                        unless ("$evt" eq 1) {
+                            $e->rollback;
+                            return $evt;
+                        }
                     }
                 }
-            }
+            } 
         }
-    }
-
-    _create_reset_reason_entry($e,$hold,OILS_HOLD_MANUAL_RESET,$note_body);
+        if( $copy->status == OILS_COPY_STATUS_MISSING ) {
+            $reset_note.=" Copy marked missing.";
+            
+        } elsif( $copy->status == OILS_COPY_STATUS_DAMAGED ) {
+            $reset_note.=" Copy marked damaged.";
+            
+        } elsif( $copy->status == OILS_COPY_STATUS_DISCARD ) {
+            $reset_note.=" Copy marked discarded.";      
+        }        
+    }
+
+    _create_reset_reason_entry($e,$hold,$reset_reason,$reset_note) if $reset_reason;
     $hold->clear_capture_time;
     $hold->clear_current_copy;
     $hold->clear_shelf_time;
@@ -4516,7 +4526,7 @@ sub change_hold_title {
 
     $e->commit;
 
-    _reset_hold($self, $e->requestor, $_) for @$holds;
+    _reset_hold($self, $e->requestor, $_, OILS_HOLD_UPDATED, "title hold target change") for @$holds;
 
     return 1;
 }
@@ -4553,7 +4563,7 @@ sub change_hold_title_for_specific_holds {
 
     $e->commit;
 
-    _reset_hold($self, $e->requestor, $_) for @$holds;
+    _reset_hold($self, $e->requestor, $_, OILS_HOLD_UPDATED, "title hold target change") for @$holds;
 
     return 1;
 }
index 7da498a..8dd9045 100644 (file)
             <div class="flex-cell strong-text">Time</div>
             <div class="flex-cell strong-text">Reason</div>
             <div class="flex-cell strong-text">Requestor</div>
+            <div class="flex-cell strong-text">Requestor Workstation</div>
             <div class="flex-cell strong-text">Note</div>
             <div class="flex-cell strong-text">Previous Copy</div>
         </div>
             <div class="flex-cell">{{reset.reset_time() | date:$root.egDateAndTimeFormat}}</div>
             <div class="flex-cell">{{reset.reset_reason().name()}}</div>
             <div class="flex-cell">{{reset.requestor().usrname()}}</div>
+            <div class="flex-cell">{{reset.requestor_workstation().name()}}</div>
             <div class="flex-cell">{{reset.note()}}</div>
             <div class="flex-cell">
                 <a href="./cat/item/{{reset.previous_copy().id()}}" target="_self">
index 6779376..be73617 100644 (file)
@@ -871,7 +871,7 @@ function($window , $location , $timeout , egCore , egHolds , egCirc) {
                         {hold : $scope.hold.id()}, 
                         {
                             flesh : 1, 
-                            flesh_fields : {ahrrre : ['reset_reason','requestor','previous_copy']},                          
+                            flesh_fields : {ahrrre : ['reset_reason','requestor','requestor_workstation','previous_copy']},                          
                             limit : $scope.resetsPerPage * $scope.maximumPages
                         },
                         {atomic : true}