@@ -, +, @@ enabled --- Koha/Patron.pm | 15 +++++++++++++++ .../opac-tmpl/bootstrap/en/modules/opac-user.tt | 10 +++++----- t/Patron.t | 22 +++++++++++++++++++++- 3 files changed, 41 insertions(+), 6 deletions(-) --- a/Koha/Patron.pm +++ a/Koha/Patron.pm @@ -266,6 +266,21 @@ sub is_debarred { return; } +=head2 is_expired + +my $is_expired = $patron->is_expired; + +Returns true if the patron is passed the expiry date, false otherwise + +=cut + +sub is_expired { + my ($self) = @_; + + return 1 if $self->dateexpiry && dt_from_string( $self->dateexpiry ) < dt_from_string; + return 0; +} + =head2 update_password my $updated = $patron->update_password( $userid, $password ); --- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt +++ a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-user.tt @@ -156,7 +156,7 @@ Using this account is not recommended because some parts of Koha will not functi Barcode [% END %] Call no. - [% IF ( OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %] + [% IF ( OpacRenewalAllowed && !( borrower.is_expired && Koha.Preference('BlockExpiredPatronOpacActions') ) ) %] Renew [% END %] [% IF ( OPACFinesTab ) %] @@ -245,7 +245,7 @@ Using this account is not recommended because some parts of Koha will not functi Call no.: [% ISSUE.itemcallnumber %] - [% IF ( OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %] + [% IF ( OpacRenewalAllowed && !( borrower.is_expired && Koha.Preference('BlockExpiredPatronOpacActions') ) ) %] [% IF ISSUE.renewed %]Renewed!
[% END %] [% IF ( ISSUE.status ) %] @@ -285,12 +285,12 @@ Using this account is not recommended because some parts of Koha will not functi [% END # /FOREACH ISSUES %] - [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %] + [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && Koha.Preference('BlockExpiredPatronOpacActions') ) ) %] [% END %] - [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %] + [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && Koha.Preference('BlockExpiredPatronOpacActions') ) ) %]
@@ -876,7 +876,7 @@ Using this account is not recommended because some parts of Koha will not functi e.preventDefault(); $("#renewall").submit(); }); - [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && borrower.BlockExpiredPatronOpacActions ) ) %] + [% IF ( canrenew && !userdebarred && OpacRenewalAllowed && !( borrower.is_expired && Koha.Preference('BlockExpiredPatronOpacActions') ) ) %] $("#checkoutst caption").append("
"+_("Renew selected")+" "+_("Renew all")+"
"); [% END %] [% END %] --- a/t/Patron.t +++ a/t/Patron.t @@ -17,14 +17,16 @@ use Modern::Perl; -use Test::More tests => 11; +use Test::More tests => 13; use Test::Warn; use t::lib::Mocks; +use t::lib::Mocks qw(mock_preference); BEGIN { t::lib::Mocks::mock_dbh; use_ok('Koha::Object'); use_ok('Koha::Patron'); + use_ok('Koha::DateUtils'); } my $object = Koha::Patron->new( { surname => 'Test Patron' } ); @@ -324,4 +326,22 @@ subtest 'Set tests' => sub { is( $patron->privacy, '667789', 'privacy field set ok' ); }; +subtest 'is_expiry tests' => sub { + plan tests => 4; + + t::lib::Mocks::mock_preference( "dateformat", "iso" ); + + $patron->dateexpiry(undef); + ok( !$patron->is_expired, "Patron is not expired if expiry date is not set" ); + + $patron->dateexpiry("1900-01-01"); + ok( $patron->is_expired, "Patron is expired with expiry date 1900-01-01" ); + + $patron->dateexpiry("9999-01-01"); + ok( !$patron->is_expired, "Patron is not expired with expiry date 9999-01-01" ); + + $patron->dateexpiry( dt_from_string->ymd ); + ok( $patron->is_expired, "Patron is not expired if the expiration date is today's date" ); +}; + 1; --