From 5d7b078eaa112e8cf03764a825b4307e8682c706 Mon Sep 17 00:00:00 2001 From: erickson Date: Tue, 3 Jul 2007 11:22:41 +0000 Subject: [PATCH] backporting transit date filtering code to 1_0 and latest branch git-svn-id: svn://svn.open-ils.org/ILS/branches/rel_1_0_6@7509 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../perlmods/OpenILS/Application/Circ/Transit.pm | 45 +++++++++++----------- 1 file changed, 23 insertions(+), 22 deletions(-) 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 }; } -- 2.11.0