[open-ils-commits] r7509 - in branches:
rel_1_0/Open-ILS/src/perlmods/OpenILS/Application/Circ
rel_1_0_6/Open-ILS/src/perlmods/OpenILS/Application/Circ
svn at svn.open-ils.org
svn at svn.open-ils.org
Tue Jul 3 07:26:15 EDT 2007
Author: erickson
Date: 2007-07-03 07:22:41 -0400 (Tue, 03 Jul 2007)
New Revision: 7509
Modified:
branches/rel_1_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm
branches/rel_1_0_6/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm
Log:
backporting transit date filtering code to 1_0 and latest branch
Modified: branches/rel_1_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm
===================================================================
--- branches/rel_1_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm 2007-07-03 10:56:25 UTC (rev 7508)
+++ branches/rel_1_0/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm 2007-07-03 11:22:41 UTC (rev 7509)
@@ -317,34 +317,35 @@
);
+# 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 $order_by = {order_by => { atc => 'source_send_time' }};
+ my $search = { dest_recv_time => undef };
- my $froms = $e->search_action_transit_copy(
- [{
- source => $orgid,
- dest_recv_time => undef,
- },
- {
- order_by => { atc => 'source_send_time' }
- }],
- { idlist => 1 }
- );
+ 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 };
}
Modified: branches/rel_1_0_6/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm
===================================================================
--- branches/rel_1_0_6/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm 2007-07-03 10:56:25 UTC (rev 7508)
+++ branches/rel_1_0_6/Open-ILS/src/perlmods/OpenILS/Application/Circ/Transit.pm 2007-07-03 11:22:41 UTC (rev 7509)
@@ -317,34 +317,35 @@
);
+# 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 $order_by = {order_by => { atc => 'source_send_time' }};
+ my $search = { dest_recv_time => undef };
- my $froms = $e->search_action_transit_copy(
- [{
- source => $orgid,
- dest_recv_time => undef,
- },
- {
- order_by => { atc => 'source_send_time' }
- }],
- { idlist => 1 }
- );
+ 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 };
}
More information about the open-ils-commits
mailing list