<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"/>
<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>
</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>
<!-- ********************************************************************************************************************* -->
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;
</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>
{ flesh : 4,
flesh_fields : {
circ : ['target_copy', 'workstation', 'checkin_workstation'],
- acp : ['call_number'],
+ acp : ['call_number', 'holds_count'],
acn : ['record'],
bre : ['simple_record']
},
'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' },
}
}
},
+ {
+ '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',