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

(-)a/Koha/Patrons.pm (-13 / +25 lines)
Lines 177-182 sub anonymise_issue_history { Link Here
177
177
178
    $older_than_date = dt_from_string $older_than_date if $older_than_date;
178
    $older_than_date = dt_from_string $older_than_date if $older_than_date;
179
179
180
    my $filter_damaged =
181
      C4::Context->preference("KeepDamagedCheckouts") || 0;
182
    my $filter_lost =
183
      C4::Context->preference("KeepLostCheckouts") || 0;
184
    my $filter_withdrawn =
185
      C4::Context->preference("KeepWithdrawnCheckouts") || 0;
186
180
    # The default of 0 does not work due to foreign key constraints
187
    # The default of 0 does not work due to foreign key constraints
181
    # The anonymisation should not fail quietly if AnonymousPatron is not a valid entry
188
    # The anonymisation should not fail quietly if AnonymousPatron is not a valid entry
182
    # Set it to undef (NULL)
189
    # Set it to undef (NULL)
Lines 184-197 sub anonymise_issue_history { Link Here
184
    my $nb_rows = 0;
191
    my $nb_rows = 0;
185
    while ( my $patron = $self->next ) {
192
    while ( my $patron = $self->next ) {
186
        my $old_issues_to_anonymise = $patron->old_checkouts->search(
193
        my $old_issues_to_anonymise = $patron->old_checkouts->search(
187
        {
194
            {
188
            (
195
                (
189
                $older_than_date
196
                    $older_than_date
190
                ? ( returndate =>
197
                    ? ( returndate =>
191
                      { '<' => $dtf->format_datetime($older_than_date) } )
198
                          { '<' => $dtf->format_datetime($older_than_date) } )
192
                : ()
199
                    : ()
193
            )
200
                ),
194
        }
201
                ( $filter_damaged   ? ( "itemnumber.damaged"   => 0 ) : () ),
202
                ( $filter_lost      ? ( "itemnumber.itemlost"  => 0 ) : () ),
203
                ( $filter_withdrawn ? ( "itemnumber.withdrawn" => 0 ) : () )
204
            },
205
            {
206
                join => ['itemnumber']
207
            }
195
        );
208
        );
196
209
197
        my $last_borrowers_to_anonymise =
210
        my $last_borrowers_to_anonymise =
Lines 202-211 sub anonymise_issue_history { Link Here
202
                    ? ( created_on =>
215
                    ? ( created_on =>
203
                          { '<' => $dtf->format_datetime($older_than_date) } )
216
                          { '<' => $dtf->format_datetime($older_than_date) } )
204
                    : (),
217
                    : (),
205
                    "itemnumber.damaged" => 0,
218
                ),
206
                    "itemnumber.itemlost" => 0,
219
                ( $filter_damaged   ? ( "itemnumber.damaged"   => 0 ) : () ),
207
                    "itemnumber.withdrawn" => 0,
220
                ( $filter_lost      ? ( "itemnumber.itemlost"  => 0 ) : () ),
208
                )
221
                ( $filter_withdrawn ? ( "itemnumber.withdrawn" => 0 ) : () )
209
            },
222
            },
210
            {
223
            {
211
                join => ['itemnumber']
224
                join => ['itemnumber']
212
- 

Return to bug 23260