From: erickson Date: Fri, 18 May 2007 16:49:45 +0000 (+0000) Subject: added optional range dates for transit start time in transit-list-by-lib method X-Git-Url: https://old-git.evergreen-ils.org/?a=commitdiff_plain;h=fb2ac3dd153b744c2f6c240f7f39f137ad75a569;p=Evergreen.git added optional range dates for transit start time in transit-list-by-lib method git-svn-id: svn://svn.open-ils.org/ILS/trunk@7328 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm index 89812c7365..ff3ad4eca8 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm @@ -317,33 +317,34 @@ __PACKAGE__->register_method( ); +# start_date and end_date are optional endpoints for the transit creation date sub transits_by_lib { - my( $self, $conn, $auth, $orgid ) = @_; + my( $self, $conn, $auth, $orgid, $start_date, $end_date ) = @_; my $e = new_editor(authtoken=>$auth); return $e->event unless $e->checkauth; return $e->event unless $e->allowed('VIEW_CIRCULATIONS'); # eh.. basically the same permission - my $tos = $e->search_action_transit_copy( - [{ - dest => $orgid, - dest_recv_time => undef, - }, - { - order_by => { atc => 'source_send_time' } - }], - { idlist => 1 } - ); - - my $froms = $e->search_action_transit_copy( - [{ - source => $orgid, - dest_recv_time => undef, - }, - { - order_by => { atc => 'source_send_time' } - }], - { idlist => 1 } - ); + my $order_by = {order_by => { atc => 'source_send_time' }}; + my $search = { dest_recv_time => undef }; + + if($end_date) { + if($start_date) { + $search->{source_send_time} = {between => [$start_date, $end_date]}; + } else { + $search->{source_send_time} = {'<=' => $end_date}; + } + } elsif($start_date) { + $search->{source_send_time} = {'>=' => $start_date}; + } + + $search->{dest} = $orgid; + + my $tos = $e->search_action_transit_copy([ $search, $order_by ], {idlist=>1}); + + delete $$search{dest}; + $search->{source} = $orgid; + + my $froms = $e->search_action_transit_copy([ $search, $order_by ], {idlist=>1}); return { from => $froms, to => $tos }; }