Avoid CAPTURE-blocked holds in pull list (IDL view)
authorBill Erickson <berick@esilibrary.com>
Thu, 21 Jun 2012 18:37:11 +0000 (14:37 -0400)
committerMike Rylander <mrylander@gmail.com>
Tue, 24 Jul 2012 15:49:31 +0000 (11:49 -0400)
Update the new IDL holds pull list view to avoid returning holds for
users that have CAPTURE penalties.

Note that items are blocked from the pull list only if the hold pickup
lib is within the CAPTURE penalty org unit range.  This means that users
could be blocked at one branch, but use a pickup lib at another to avoid
the block.  To prevent this type of abuse, set the org_depth to 0 on any
penalties that apply the CAPTURE block.

Signed-off-by: Bill Erickson <berick@esilibrary.com>
Signed-off-by: Jason Stephenson <jstephenson@mvlc.org>
Signed-off-by: Mike Rylander <mrylander@gmail.com>
Open-ILS/examples/fm_IDL.xml

index a3cda7c..dba33cf 100644 (file)
@@ -5048,6 +5048,18 @@ SELECT  usr,
                JOIN asset.call_number_prefix acnp ON (acn.prefix = acnp.id)
                JOIN asset.call_number_suffix acns ON (acn.suffix = acns.id)
                JOIN actor.usr au ON (au.id = ahr.usr)
+               LEFT JOIN actor.usr_standing_penalty ausp 
+                       ON (ahr.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%' AND (
+                                       (csp.org_depth IS NULL AND ahr.pickup_lib = ausp.org_unit) OR
+                                       (csp.org_depth IS NOT NULL AND ahr.pickup_lib IN (
+                                               SELECT id FROM actor.org_unit_descendants(ausp.org_unit, csp.org_depth))
+                                       )
+                               )
+                       )
                LEFT JOIN serial.issuance siss
                        ON (ahr.hold_type = 'I' AND siss.id = ahr.target)
                LEFT JOIN asset.copy_location_order acplo
@@ -5056,6 +5068,7 @@ SELECT  usr,
                WHERE
                        ahr.capture_time IS NULL AND
                        ahr.cancel_time IS NULL AND
+                       csp.id IS NULL AND
                        (ahr.expire_time is NULL OR ahr.expire_time > NOW())
                ]]></oils_persist:source_definition>
                <fields oils_persist:primary="id">