From 1b36e7a6af73c06417a4cbf19bf0585125b32a36 Mon Sep 17 00:00:00 2001
From: Bill Erickson <berick@esilibrary.com>
Date: Tue, 10 Apr 2012 16:24:59 -0400
Subject: [PATCH] Avoid CAPTURE-blocked holds in pull list

Otherwise, staff will be pulling items for holds that cannot be
captured.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
---
 .../lib/OpenILS/Application/Storage/Publisher/action.pm        | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
index 78b05961ac..d80fbafd93 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
@@ -505,10 +505,15 @@ sub hold_pull_list {
 		  FROM	$h_table h
 		  	JOIN $a_table a ON (h.current_copy = a.id)
 		  	LEFT JOIN $ord_table ord ON (a.location = ord.location AND a.circ_lib = ord.org)
+			LEFT JOIN actor.usr_standing_penalty ausp 
+				ON ( h.usr = ausp.usr AND ( ausp.stop_date IS NULL OR ausp.stop_date > NOW() ) )
+			LEFT JOIN config.standing_penalty csp
+				ON ( csp.id = ausp.standing_penalty AND csp.block_list LIKE '%CAPTURE%' )
 		  WHERE	a.circ_lib = ?
 		  	AND h.capture_time IS NULL
 		  	AND h.cancel_time IS NULL
 		  	AND (h.expire_time IS NULL OR h.expire_time > NOW())
+			AND csp.id IS NULL
 			$status_filter
 		  ORDER BY CASE WHEN ord.position IS NOT NULL THEN ord.position ELSE 999 END, h.request_time
 		  LIMIT $limit
@@ -520,10 +525,15 @@ sub hold_pull_list {
             SELECT    count(*)
               FROM    $h_table h
                   JOIN $a_table a ON (h.current_copy = a.id)
+                  LEFT JOIN actor.usr_standing_penalty ausp 
+                    ON ( h.usr = ausp.usr AND ( ausp.stop_date IS NULL OR ausp.stop_date > NOW() ) )
+                  LEFT JOIN config.standing_penalty csp
+                    ON ( csp.id = ausp.standing_penalty AND csp.block_list LIKE '%CAPTURE%' )
               WHERE    a.circ_lib = ?
                   AND h.capture_time IS NULL
                   AND h.cancel_time IS NULL
                   AND (h.expire_time IS NULL OR h.expire_time > NOW())
+                  AND csp.id IS NULL
                 $status_filter
         SQL
     }
-- 
2.11.0