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

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

Return to bug 23260