added ability to flesh picklist entry count for summary displays
authorerickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Feb 2008 14:37:19 +0000 (14:37 +0000)
committererickson <erickson@dcc99617-32d9-48b4-a31d-7c20da2025e4>
Tue, 12 Feb 2008 14:37:19 +0000 (14:37 +0000)
git-svn-id: svn://svn.open-ils.org/ILS/branches/acq-experiment@8729 dcc99617-32d9-48b4-a31d-7c20da2025e4

Open-ILS/examples/fm_IDL.xml
Open-ILS/src/perlmods/OpenILS/Application/Acq/Picklist.pm

index 16e6083..15480c8 100644 (file)
                        <field reporter:label="Creation Time" name="create_time" oils_obj:array_position="6" oils_persist:virtual="false" reporter:datatype="timestamp" />
                        <field reporter:label="Edit Time" name="edit_time" oils_obj:array_position="7" oils_persist:virtual="false" reporter:datatype="timestamp" />
                        <field reporter:label="Entries" name="entries" oils_obj:array_position="8" oils_persist:virtual="true" reporter:datatype="link" />
+                       <field reporter:label="Entry Count" name="entry_count" oils_obj:array_position="9" oils_persist:virtual="true"/>
                </fields>
                <links>
                        <link field="owner" reltype="has_a" key="id" map="" class="au"/>
index 16955de..5b64eb4 100644 (file)
@@ -75,6 +75,7 @@ __PACKAGE__->register_method(
         params => [
             {desc => 'Authentication token', type => 'string'},
             {desc => 'Picklist ID to retrieve', type => 'number'},
+            {desc => 'Options hash, including "flesh_entry_count" to get the count of attached entries', type => 'hash'},
         ],
         return => {desc => 'Picklist object on success, Event on error'}
     }
@@ -88,6 +89,17 @@ sub retrieve_picklist {
     my $picklist = $e->retrieve_acq_picklist($picklist_id)
         or return $e->event;
 
+    if($$options{flesh_entry_count}) {
+        my $count = $e->json_query({
+            select => { 
+                acqple => [{transform => 'count', column => 'id', alias => 'count'}]
+            }, 
+            from => 'acqple', 
+            where => {picklist => $picklist_id}}
+        );
+        $picklist->entry_count($count->[0]->{count});
+    }
+
     return $BAD_PARAMS unless $e->requestor->id == $picklist->owner;
     return $picklist;
 }