Consider aous hold_shelf delay when displaying available hold count. user/bott/copy_note_functions_for_upgrade
authorBill Ott <bott@grpl.org>
Thu, 8 Jun 2017 18:30:39 +0000 (14:30 -0400)
committerBill Ott <bott@grpl.org>
Thu, 8 Jun 2017 18:30:39 +0000 (14:30 -0400)
Signed-off-by: Bill Ott <bott@grpl.org>
Open-ILS/src/perlmods/lib/OpenILS/Application/Actor.pm

index 6cc2e8b..7de1060 100644 (file)
@@ -2024,7 +2024,7 @@ sub hold_request_count {
     }
 
     my $holds = $e->json_query({
-        select => {ahr => ['pickup_lib', 'current_shelf_lib', 'behind_desk']},
+        select => {ahr => ['pickup_lib', 'current_shelf_lib', 'shelf_time', 'behind_desk']},
         from => 'ahr',
         where => {
             usr => $user_id,
@@ -2033,9 +2033,33 @@ sub hold_request_count {
         }
     });
 
+    my $now = DateTime->now(time_zone => 'local');
+    foreach (@$holds){
+        if($_->{current_shelf_lib}) {
+            my $delay = $e->json_query({
+                select => {aous => ['value']},
+                from => 'aous',
+                where => {
+                    name => {"=" => 'circ.hold_shelf_status_delay'},
+                    org_unit => {"=" => $_->{current_shelf_lib}}
+                }
+            })->[0];
+
+            my $dtime = DateTime::Format::ISO8601->parse_datetime(clense_ISO8601($_->{shelf_time}));
+            if ($delay->{value}){
+                $dtime->add( seconds => OpenSRF::Utils::interval_to_seconds($delay->{value}) );
+                $_->{delay} = $dtime;
+            }else{
+                $_->{delay} = $now;
+            }
+            $logger->info("now / delay / dleay_date ".$now." / ". $delay->{value}." / ".$dtime);
+        }
+    }
+
     my @ready = grep {
         $_->{current_shelf_lib} and # avoid undef warnings
         $_->{pickup_lib} eq $_->{current_shelf_lib}
+       and $now ge $_->{delay}
     } @$holds;
 
     my $resp = {