View | Details | Raw Unified | Return to bug 26053
Collapse All | Expand All

(-)a/Koha/Patron/Restriction.pm (+16 lines)
Lines 18-23 package Koha::Patron::Restriction; Link Here
18
use Modern::Perl;
18
use Modern::Perl;
19
19
20
use Koha::Database;
20
use Koha::Database;
21
use Koha::DateUtils qw( dt_from_string );
21
use Koha::Patron::Restriction::Type;
22
use Koha::Patron::Restriction::Type;
22
23
23
use base qw(Koha::Object);
24
use base qw(Koha::Object);
Lines 44-49 sub type { Link Here
44
    return Koha::Patron::Restriction::Type->_new_from_dbic($type_rs);
45
    return Koha::Patron::Restriction::Type->_new_from_dbic($type_rs);
45
}
46
}
46
47
48
=head3 is_expired
49
50
my $is_expired = $restriction->is_expired;
51
52
Returns 1 if the restriction is expired or 0;
53
54
=cut
55
56
sub is_expired {
57
    my ($self) = @_;
58
    return 0 unless $self->expiration;
59
    return 1 if dt_from_string( $self->expiration ) < dt_from_string->truncate( to => 'day' );
60
    return 0;
61
}
62
47
=head2 Internal methods
63
=head2 Internal methods
48
64
49
=head3 _type
65
=head3 _type
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/patron-restrictions-tab.inc (-3 / +10 lines)
Lines 19-25 Link Here
19
        </thead>
19
        </thead>
20
        <tbody>
20
        <tbody>
21
            [% FOREACH restriction IN patron.restrictions %]
21
            [% FOREACH restriction IN patron.restrictions %]
22
                <tr>
22
                [% restriction_tr_class = restriction.is_expired ? "text-muted" : "" %]
23
                <tr class="[% restriction_tr_class | html %]">
23
                    <td>
24
                    <td>
24
                        [% PROCESS restriction_type_description restriction_type=restriction.type %]
25
                        [% PROCESS restriction_type_description restriction_type=restriction.type %]
25
                    </td>
26
                    </td>
Lines 30-36 Link Here
30
                            [% restriction.comment | $raw %]
31
                            [% restriction.comment | $raw %]
31
                        [% END %]
32
                        [% END %]
32
                    </td>
33
                    </td>
33
                    <td>[% IF restriction.expiration %] [% restriction.expiration | $KohaDates %] [% ELSE %] <em>Indefinite</em> [% END %]</td>
34
                    <td>
35
                        [% IF restriction.expiration %]
36
                            [% restriction.expiration | $KohaDates %]
37
                            [% IF restriction.is_expired %]<span>(expired)<span>[% END %]
38
                        [% ELSE %]
39
                            <em>Indefinite</em>
40
                        [% END %]
41
                    </td>
34
                    <td>[% restriction.created | $KohaDates %]</td>
42
                    <td>[% restriction.created | $KohaDates %]</td>
35
                    [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %]
43
                    [% IF CAN_user_borrowers_edit_borrowers && CAN_user_circulate_manage_restrictions %]
36
                        <td>
44
                        <td>
37
- 

Return to bug 26053