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

(-)a/Koha/Old/Checkouts.pm (-1 / +71 lines)
Lines 23-28 use Koha::Old::Checkout; Link Here
23
23
24
use base qw(Koha::Objects);
24
use base qw(Koha::Objects);
25
25
26
=head1 NAME
27
28
Koha::Old::Checkouts - Koha Old Checkouts object set class
29
30
This object represents a set of completed checkouts
31
32
=head1 API
33
34
=head2 Class methods
35
36
=head3 filter_by_anonymizable
37
38
    my $checkouts = $patron->old_checkouts;
39
    my $anonymizable_checkouts = $checkouts->filter_by_anonymizable;
40
41
This method filters the resultset, so it only contains checkouts that can be
42
anonymized given the patron privacy settings.
43
44
=cut
45
46
sub filter_by_anonymizable {
47
    my ( $self, $params ) = @_;
48
49
    my $anonymous_patron = C4::Context->preference('AnonymousPatron') || undef;
50
51
    return $self->search(
52
        {
53
            'me.borrowernumber' => { 'not' => undef },
54
            'patron.privacy' => { '<>'  => 0 },
55
            (
56
                $anonymous_patron
57
                ? ( 'me.borrowernumber' => { '!=' => $anonymous_patron } )
58
                : ()
59
            ),
60
        },
61
        {
62
            join     => ['patron'],
63
        }
64
    );
65
}
66
67
=head3 filter_by_todays_checkins
68
69
=cut
70
26
sub filter_by_todays_checkins {
71
sub filter_by_todays_checkins {
27
    my ( $self ) = @_;
72
    my ( $self ) = @_;
28
73
Lines 40-49 sub filter_by_todays_checkins { Link Here
40
    });
85
    });
41
}
86
}
42
87
88
=head3 anonymize
89
90
    $patron->old_checkouts->anonymize();
91
92
Anonymize the given I<Koha::Old::Checkouts> resultset.
93
94
=cut
95
96
sub anonymize {
97
    my ( $self, $params ) = @_;
98
99
    my $anonymous_id = C4::Context->preference('AnonymousPatron') || undef;
100
101
    return $self->update( { borrowernumber => $anonymous_id }, { no_triggers => 1 } );
102
}
103
104
=head2 Internal methods
105
106
=head3 _type
107
108
=cut
109
43
sub _type {
110
sub _type {
44
    return 'OldIssue';
111
    return 'OldIssue';
45
}
112
}
46
113
114
=head3 object_class
115
116
=cut
117
47
sub object_class {
118
sub object_class {
48
    return 'Koha::Old::Checkout';
119
    return 'Koha::Old::Checkout';
49
}
120
}
50
- 

Return to bug 29843