<field name="xact" oils_persist:virtual="true" reporter:datatype="link"/>
<field name="grocery" oils_persist:virtual="true" reporter:datatype="link"/>
<field name="circulation" oils_persist:virtual="true" reporter:datatype="link"/>
+ <field name="reservation" oils_persist:virtual="true" reporter:datatype="link"/>
<field name="billing_location" reporter:datatype="link"/>
</fields>
<links>
<link field="xact" reltype="might_have" key="id" map="" class="mbt"/>
<link field="circulation" reltype="might_have" key="id" map="" class="circ"/>
<link field="grocery" reltype="might_have" key="id" map="" class="mg"/>
+ <link field="reservation" reltype="might_have" key="id" map="" class="bresv"/>
<link field="billing_location" reltype="has_a" key="id" map="" class="aou"/>
</links>
</class>
</actions>
</permacrud>
</class>
+ <class id="cbc" controller="open-ils.cstore open-ils.pcrud" oils_obj:fieldmapper="config::barcode_completion" oils_persist:tablename="config.barcode_completion" reporter:label="Barcode Completions">
+ <fields oils_persist:primary="id" oils_persist:sequence="config.barcode_completion_id_seq">
+ <field reporter:label="ID" name="id" reporter:datatype="id"/>
+ <field reporter:label="Active" name="active" reporter:datatype="bool"/>
+ <field reporter:label="Owner" name="org_unit" reporter:datatype="org_unit"/>
+ <field reporter:label="Prefix" name="prefix" reporter:datatype="text"/>
+ <field reporter:label="Suffix" name="suffix" reporter:datatype="text"/>
+ <field reporter:label="Length" name="length" reporter:datatype="int"/>
+ <field reporter:label="Padding" name="padding" reporter:datatype="text"/>
+ <field reporter:label="Padding At End" name="padding_end" reporter:datatype="bool"/>
+ <field reporter:label="Applies to Items" name="asset" reporter:datatype="bool"/>
+ <field reporter:label="Applies to Users" name="actor" reporter:datatype="bool"/>
+ </fields>
+ <links>
+ <link field="org_unit" reltype="has_a" key="id" map="" class="aou"/>
+ </links>
+ <permacrud xmlns="http://open-ils.org/spec/opensrf/IDL/permacrud/v1">
+ <actions>
+ <create permission="UPDATE_ORG_UNIT_SETTING_ALL" context_field="org_unit"/>
+ <retrieve/>
+ <update permission="UPDATE_ORG_UNIT_SETTING_ALL" context_field="org_unit"/>
+ <delete permission="UPDATE_ORG_UNIT_SETTING_ALL" context_field="org_unit"/>
+ </actions>
+ </permacrud>
+ </class>
<!-- ********************************************************************************************************************* -->
);
sub hold_request_count {
- my( $self, $client, $login_session, $userid ) = @_;
-
- my( $user_obj, $target, $evt ) = $apputils->checkses_requestor(
- $login_session, $userid, 'VIEW_HOLD' );
- return $evt if $evt;
-
-
- my $holds = $apputils->simple_scalar_request(
- "open-ils.cstore",
- "open-ils.cstore.direct.action.hold_request.search.atomic",
- {
- usr => $userid,
- fulfillment_time => {"=" => undef },
- cancel_time => undef,
- }
- );
+ my( $self, $client, $authtoken, $user_id ) = @_;
+ my $e = new_editor(authtoken => $authtoken);
+ return $e->event unless $e->checkauth;
- my @ready;
- for my $h (@$holds) {
- next unless $h->capture_time and $h->current_copy;
+ $user_id = $e->requestor->id unless defined $user_id;
- my $copy = $apputils->simple_scalar_request(
- "open-ils.cstore",
- "open-ils.cstore.direct.asset.copy.retrieve",
- $h->current_copy
- );
+ if($e->requestor->id ne $user_id) {
+ my $user = $e->retrieve_actor_user($user_id);
+ return $e->event unless $e->allowed('VIEW_HOLD', $user->home_ou);
+ }
- if ($copy and $copy->status == 8) {
- push @ready, $h;
- }
- }
+ my $holds = $e->json_query({
+ select => {ahr => ['shelf_time']},
+ from => 'ahr',
+ where => {
+ usr => $user_id,
+ fulfillment_time => {"=" => undef },
+ cancel_time => undef,
+ }
+ });
- return { total => scalar(@$holds), ready => scalar(@ready) };
+ return {
+ total => scalar(@$holds),
+ ready => scalar(grep { $_->{shelf_time} } @$holds)
+ };
}
__PACKAGE__->register_method(
return $res;
}
+ __PACKAGE__->register_method(
+ method => "get_barcodes",
+ api_name => "open-ils.actor.get_barcodes"
+ );
+
+ sub get_barcodes {
+ my( $self, $client, $auth, $org_id, $context, $barcode ) = @_;
+ my $e = new_editor(authtoken => $auth);
+ return $e->event unless $e->checkauth;
+ return $e->event unless $e->allowed('STAFF_LOGIN', $org_id);
+ my $db_result = $e->json_query(
+ { from => [
+ 'evergreen.get_barcodes',
+ $org_id, $context, $barcode,
+ ]
+ }
+ );
+ if($context =~ /actor/) {
+ my $filter_result = ();
+ my $patron;
+ foreach my $result (@$db_result) {
+ if($result->{type} eq 'actor') {
+ if($e->requestor->id != $result->{id}) {
+ $patron = $e->retrieve_actor_user($result->{id});
+ if(!$patron) {
+ push(@$filter_result, $e->event);
+ next;
+ }
+ if($e->allowed('VIEW_USER', $patron->home_ou)) {
+ push(@$filter_result, $result);
+ }
+ else {
+ push(@$filter_result, $e->event);
+ }
+ }
+ else {
+ push(@$filter_result, $result);
+ }
+ }
+ else {
+ push(@$filter_result, $result);
+ }
+ }
+ return $filter_result;
+ }
+ else {
+ return $db_result;
+ }
+ }
1;