From 4475711331db8acaf3ae79fd308c59681f74201e Mon Sep 17 00:00:00 2001
From: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Date: Wed, 27 Jun 2012 18:38:19 -0400
Subject: [PATCH] Add two fields to the new FlattenerGrid-based hold pull list

Namely (current) copy status and (number of) potential copies.

I believe this implementation has a negligible impact on the efficiency
of the hold pull list query overall.

Signed-off-by: Lebbeous Fogle-Weekley <lebbeous@esilibrary.com>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
---
 Open-ILS/examples/fm_IDL.xml                   | 9 ++++++++-
 Open-ILS/src/templates/circ/hold_pull_list.tt2 | 1 +
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/Open-ILS/examples/fm_IDL.xml b/Open-ILS/examples/fm_IDL.xml
index f7ef3fa084..5b9725a6b0 100644
--- a/Open-ILS/examples/fm_IDL.xml
+++ b/Open-ILS/examples/fm_IDL.xml
@@ -5048,7 +5048,8 @@ SELECT  usr,
 			TRIM(acnp.label || ' ' || acn.label || ' ' || acns.label)
 				AS call_number_label,
 			siss.label AS issuance_label,
-			(ahr.usr <> ahr.requestor) AS is_staff_hold
+			(ahr.usr <> ahr.requestor) AS is_staff_hold,
+			ahcm_1.copy_count AS potential_copies
 		FROM action.hold_request ahr
 		JOIN asset.copy acp ON (acp.id = ahr.current_copy)
 		JOIN asset.call_number acn ON (acp.call_number = acn.id)
@@ -5071,6 +5072,11 @@ SELECT  usr,
 					)
 				)
 			)
+		JOIN (
+			SELECT COUNT(target_copy) AS copy_count, hold
+			FROM action.hold_copy_map
+			GROUP BY 2
+		) ahcm_1 ON (ahcm_1.hold = ahr.id)
 		LEFT JOIN serial.issuance siss
 			ON (ahr.hold_type = 'I' AND siss.id = ahr.target)
 		LEFT JOIN asset.copy_location_order acplo
@@ -5128,6 +5134,7 @@ SELECT  usr,
 			<field reporter:label="Call Number Label" name="call_number_label" reporter:datatype="text" />
 			<field reporter:label="Issuance Label" name="issuance_label" reporter:datatype="text" />
 			<field reporter:label="Is Staff Hold?" name="is_staff_hold" reporter:datatype="bool" />
+			<field reporter:label="Potential Copies" name="potential_copies" reporter:datatype="int" />
 		</fields>
 		<links>
 			<link field="fulfillment_lib" reltype="has_a" key="id" map="" class="aou"/>
diff --git a/Open-ILS/src/templates/circ/hold_pull_list.tt2 b/Open-ILS/src/templates/circ/hold_pull_list.tt2
index b468136657..91a2fdc067 100644
--- a/Open-ILS/src/templates/circ/hold_pull_list.tt2
+++ b/Open-ILS/src/templates/circ/hold_pull_list.tt2
@@ -89,6 +89,7 @@
                 <th field="title" fpath="current_copy.call_number.record.simple_record.title" ffilter="true">Title</th>
                 <th field="barcode" fpath="current_copy.barcode" ffilter="true"></th>
                 <th field="parts" fpath="current_copy.parts.label" fsort="false">Parts</th>
+                <th field="copy_status" fpath="current_copy.status.name">Copy Status</th>
                 <th field="notes" fpath="notes.body" fsort="false" _visible="false">Hold Notes</th>
                 <th field="patron_barcode" fpath="usr.card.barcode" _visible="false" ffilter="true">Patron Barcode</th>
                 <th field="pickup_lib_name" fpath="pickup_lib.name" _visible="false" ffilter="true">Pickup Library</th>
-- 
2.11.0