diff --git a/Koha/Patron/Restriction.pm b/Koha/Patron/Restriction.pm index 81f562fa30..5fa0952087 100644 --- a/Koha/Patron/Restriction.pm +++ b/Koha/Patron/Restriction.pm @@ -18,6 +18,7 @@ package Koha::Patron::Restriction; use Modern::Perl; use Koha::Database; +use Koha::DateUtils qw( dt_from_string ); use Koha::Patron::Restriction::Type; use base qw(Koha::Object); @@ -44,6 +45,23 @@ sub type { return Koha::Patron::Restriction::Type->_new_from_dbic($type_rs); } +=head3 is_expired + +my $is_expired = $restriction->is_expired; + +Returns 1 if the restriction is expired or 0; + +=cut + +sub is_expired { + my ($self) = @_; + return 0 unless $self->expiration; + # This condition must be consistent with Koha::Patron->is_debarred + my $makes_patron_debarred = dt_from_string( $self->expiration ) > dt_from_string; + return 1 unless $makes_patron_debarred; + return 0; +} + =head2 Internal methods =head3 _type diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc index 20a9eaf19c..cd5b4b2d99 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc @@ -19,7 +19,7 @@
[% FOREACH restriction IN patron.restrictions %] -