X-Git-Url: http://git.rot13.org/?a=blobdiff_plain;f=Koha%2FClubs.pm;h=eeaf4ef3373846b269f3ccc4db294fb9b42acaa9;hb=9add683d82b1a6db3cf62be5dca8d16c4d328207;hp=fff88d80fab9888ddfc887fd3f75837819b3a73d;hpb=4f1eefdbb8bf4df07b03fc451c1c18ebe989c8b7;p=koha.git diff --git a/Koha/Clubs.pm b/Koha/Clubs.pm index fff88d80fa..eeaf4ef337 100644 --- a/Koha/Clubs.pm +++ b/Koha/Clubs.pm @@ -22,6 +22,7 @@ use Modern::Perl; use Carp; use Koha::Database; +use Koha::DateUtils qw( dt_from_string ); use Koha::Club; @@ -56,6 +57,20 @@ sub get_enrollable { } } + my $dtf = Koha::Database->new->schema->storage->datetime_parser; + + # Only clubs with no end date or an end date in the future can be enrolled in + $params->{'-and'} = [ + -or => [ + date_end => { '>=' => $dtf->format_datetime( dt_from_string() ) }, + date_end => undef, + ], + -or => [ + 'me.branchcode' => $borrower->branchcode, + 'me.branchcode' => undef, + ] + ]; + my $rs = $self->_resultset()->search( $params, { prefetch => 'club_template' } ); if (wantarray) {