LP1402770_column_picker_option_for_number_of_holds
authorblake <blake@mobiusconsortium.org>
Mon, 20 Jul 2015 15:11:22 +0000 (10:11 -0500)
committerBen Shum <ben@evergreener.net>
Thu, 25 Feb 2016 04:48:38 +0000 (23:48 -0500)
Added a virtual IDL defintion. Added a OpenSRF method to return
the number of holds that a copy is a member of action.hold_copy_map.
Added javascript column definition to surface this in the xul staff client.
Added the column in the web based staff client as well.

Signed-off-by: blake <blake@mobiusconsortium.org>
Signed-off-by: Andrea Neiman <aneiman@kent.lib.md.us>
Signed-off-by: Kathy Lussier <klussier@masslnc.org>
Signed-off-by: Ben Shum <ben@evergreener.net>
Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/lib/OpenILS/Application/Circ/Holds.pm
Open-ILS/src/templates/staff/circ/patron/t_items_out.tt2
Open-ILS/web/js/ui/default/staff/circ/patron/items_out.js
Open-ILS/xul/staff_client/chrome/content/main/constants.js
Open-ILS/xul/staff_client/server/circ/util.js

index 42b66f2..981ccbb 100644 (file)
@@ -6674,6 +6674,7 @@ SELECT  usr,
                        <field reporter:label="Peer Record Maps" name="peer_record_maps" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Peer Records" name="peer_records" oils_persist:virtual="true" reporter:datatype="link"/>
                        <field reporter:label="Last Captured Hold" name="last_captured_hold" oils_persist:virtual="true" reporter:datatype="link"/>
+                       <field reporter:label="Has Holds" name="holds_count" oils_persist:virtual="true" reporter:datatype="link"/>
                </fields>
                <links>
                        <link field="age_protect" reltype="has_a" key="id" map="" class="crahp"/>
@@ -6698,6 +6699,7 @@ SELECT  usr,
                        <link field="peer_records" reltype="has_many" key="target_copy" map="peer_record" class="bpbcm"/>
                        <link field="last_captured_hold" reltype="has_a" key="current_copy" map="" class="alhr"/>
                        <link field="floating" reltype="has_a" key="id" map="" class="cfg"/>
+                       <link field="holds_count" reltype="might_have" key="id" map="" class="hasholdscount"/>
                </links>
         <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
             <actions>
@@ -11346,6 +11348,29 @@ SELECT  usr,
                        </actions>
                </permacrud>
        </class>
+       <class id="hasholdscount" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="action::has_holds_count" reporter:label="Copy Has Holds Count" oils_persist:readonly="true">
+        <oils_persist:source_definition>
+       SELECT ahcm.target_copy AS "id",count(*) AS "count"
+        FROM
+        action.hold_request ahr,
+        action.hold_copy_map ahcm
+        WHERE
+        ahr.cancel_time IS NULL AND
+        ahr.fulfillment_time IS NULL AND
+        ahr.capture_time IS NULL AND
+        ahr.id = ahcm.hold
+        GROUP BY ahcm.target_copy
+        </oils_persist:source_definition>
+        <fields oils_persist:primary="id">
+            <field reporter:label="Copy ID" name="id" reporter:datatype="id"/>
+            <field reporter:label="Holds Count" name="count" reporter:datatype="text"/>
+        </fields>
+       <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+            <actions>
+               <retrieve/>
+            </actions>
+       </permacrud>
+        </class>
 
        <!-- ********************************************************************************************************************* -->
 
index a859f11..65c3a6f 100644 (file)
@@ -4410,4 +4410,40 @@ sub mr_hold_filter_attrs {
     return;
 }
 
+__PACKAGE__->register_method(
+    method        => "copy_has_holds_count",
+    api_name      => "open-ils.circ.copy.has_holds_count",
+    authoritative => 1,
+    signature     => {
+        desc => q/
+            Returns the number of holds a paticular copy has
+        /,
+        params => [
+            { desc => 'Authentication Token', type => 'string'},
+            { desc => 'Copy ID', type => 'number'}
+        ],
+        return => {
+            desc => q/
+                Simple count value
+            /,
+            type => 'number'
+        }
+    }
+);
+
+sub copy_has_holds_count {
+    my( $self, $conn, $auth, $copyid ) = @_;
+    my $e = new_editor(authtoken=>$auth);
+    return $e->event unless $e->checkauth;
+
+    if( $copyid && $copyid > 0 ) {
+        my $meth = 'retrieve_action_has_holds_count';
+        my $data = $e->$meth($copyid);
+        if($data){
+                return $data->count();
+        }
+    }
+    return 0;
+}
+
 1;
index 24b4e0e..270ef90 100644 (file)
@@ -90,6 +90,7 @@
     </a>
   </eg-grid-field>
   <eg-grid-field path="*" hidden></eg-grid-field>
+  <eg-grid-field path="target_copy.holds_count.count" hidden></eg-grid-field>
   <eg-grid-field path="target_copy.circ_modifier" hidden></eg-grid-field>
   <eg-grid-field path="target_copy.*" hidden></eg-grid-field>
   <eg-grid-field path="target_copy.call_number.*" hidden></eg-grid-field>
index 3bd2b2a..380c42c 100644 (file)
@@ -98,7 +98,7 @@ function($scope,  $q,  $routeParams,  $timeout,  egCore , egUser,  patronSvc , $
             {   flesh : 4,
                 flesh_fields : {
                     circ : ['target_copy', 'workstation', 'checkin_workstation'],
-                    acp : ['call_number'],
+                    acp : ['call_number', 'holds_count'],
                     acn : ['record'],
                     bre : ['simple_record']
                 },
index e17a897..0165ec5 100644 (file)
@@ -243,6 +243,7 @@ var api = {
     'FM_CIRC_RETRIEVE_VIA_USER.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.authoritative' },
     'FM_CIRC_RETRIEVE_VIA_COPY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy_checkout_history.retrieve' },
     /*'FM_CIRC_COUNT_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.count' },*/
+    'FM_CIRC_HAS_HOLDS_COUNT_RETRIEVE_VIA_COPY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.copy.has_holds_count', 'secure' : true },
     'FM_CIRC_COUNT_RETRIEVE_VIA_USER' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.count', 'cacheable' : true, 'ttl' : 60000 },
     'FM_CIRC_COUNT_RETRIEVE_VIA_USER.authoritative' : { 'app' : 'open-ils.actor', 'method' : 'open-ils.actor.user.checked_out.count.authoritative', 'cacheable' : true, 'ttl' : 60000 },
     'FM_CIRC_COUNT_RETRIEVE_VIA_COPY' : { 'app' : 'open-ils.circ', 'method' : 'open-ils.circ.circulation.count' },
index 1af3646..3c9bff8 100644 (file)
@@ -592,6 +592,17 @@ circ.util.columns = function(modify,params) {
                 }
             }
         },
+       {
+            'id' : 'ahhc',
+            'fm_class' : 'hasholdscount',
+            'label' : 'Holds Count',
+            'flex' : 1,
+            'primary' : false,
+            'hidden' : false,
+            'editable' : false, 'render' : function(my) {
+               return network.simple_request("FM_CIRC_HAS_HOLDS_COUNT_RETRIEVE_VIA_COPY",[ ses(), my.acp.id() ] );
+               }
+        },
         {
             'id' : 'prefix',
             'fm_class' : 'acn',