From 57f36baed96ac046b4d64e2861c6031328029ad6 Mon Sep 17 00:00:00 2001 From: erickson Date: Wed, 2 Dec 2009 15:07:22 +0000 Subject: [PATCH] clean up open-ils.circ.actor.user.checked_out some. no longer using open_circulation view git-svn-id: svn://svn.open-ils.org/ILS/trunk@15054 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Circ.pm | 64 ++++++++++++------- 1 file changed, 40 insertions(+), 24 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm index 54f7b6384a..cdd595156b 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm @@ -107,44 +107,60 @@ sub ranged_billing_types { __PACKAGE__->register_method( method => "checkouts_by_user", api_name => "open-ils.circ.actor.user.checked_out", + stream => 1, NOTES => <<" NOTES"); Returns a list of open circulations as a pile of objects. Each object contains the relevant copy, circ, and record NOTES sub checkouts_by_user { - my( $self, $client, $user_session, $user_id ) = @_; - - my( $requestor, $target, $copy, $record, $evt ); - - ( $requestor, $target, $evt ) = - $apputils->checkses_requestor( $user_session, $user_id, 'VIEW_CIRCULATIONS'); - return $evt if $evt; - - my $circs = $apputils->simplereq( - 'open-ils.cstore', - "open-ils.cstore.direct.action.open_circulation.search.atomic", - { usr => $target->id, checkin_time => undef } ); -# { usr => $target->id } ); + my($self, $client, $auth, $user_id) = @_; - my @results; - for my $circ (@$circs) { + my $e = new_editor(authtoken=>$auth); + return $e->event unless $e->checkauth; - ( $copy, $evt ) = $apputils->fetch_copy($circ->target_copy); - return $evt if $evt; + my $circ_ids = $e->search_action_circulation( + { usr => $user_id, + checkin_time => undef, + '-or' => [ + {stop_fines => undef}, + {stop_fines => ['MAXFINES','LONGOVERDUE']} + ] + }, + {idlist => 1} + ); - $logger->debug("Retrieving record for copy " . $circ->target_copy); + for my $id (@$circ_ids) { + my $circ = $e->retrieve_action_circulation([ + $id, + { flesh => 3, + flesh_fields => { + circ => ['target_copy'], + acp => ['call_number'], + acn => ['record'] + } + } + ]); - ($record, $evt) = $apputils->fetch_record_by_copy( $circ->target_copy ); - return $evt if $evt; + # un-flesh for consistency + my $c = $circ->target_copy; + $circ->target_copy($c->id); - my $mods = $apputils->record_to_mvr($record); + my $cn = $c->call_number; + $c->call_number($cn->id); - push( @results, { copy => $copy, circ => $circ, record => $mods } ); - } + my $t = $cn->record; + $cn->record($t->id); - return \@results; + $client->respond( + { circ => $circ, + copy => $c, + record => $U->record_to_mvr($t) + } + ); + } + return undef; } -- 2.43.2