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

(-)a/misc/maintenance/search_for_data_inconsistencies.pl (-7 / +24 lines)
Lines 278-293 use C4::Biblio qw( GetMarcFromKohaField ); Link Here
278
}
278
}
279
279
280
{
280
{
281
    my $patrons = Koha::Patrons->search( {}, { order_by => [ 'categorycode', 'borrowernumber' ] } );
281
    my $aging_patrons = Koha::Patrons->search(
282
        {
283
            -not => {
284
                -or => {
285
                    'me.dateofbirth' => undef,
286
                    -and => {
287
                        'categorycode.dateofbirthrequired' => undef,
288
                        'categorycode.upperagelimit'       => undef,
289
                    }
290
                }
291
            }
292
        },
293
        { prefetch => ['categorycode'] },
294
        { order_by => [ 'me.categorycode', 'me.borrowernumber' ] },
295
    );
282
    my @invalid_patrons;
296
    my @invalid_patrons;
283
    while ( my $patron = $patrons->next ) {
297
    while ( my $aging_patron = $aging_patrons->next ) {
284
        push @invalid_patrons, $patron unless $patron->is_valid_age;
298
        push @invalid_patrons, $aging_patron unless $aging_patron->is_valid_age;
285
    }
299
    }
286
    if (@invalid_patrons) {
300
    if (@invalid_patrons) {
287
        new_section("Patrons with invalid age for category");
301
        new_section("Patrons with invalid age for category");
288
        foreach my $patron (@invalid_patrons) {
302
        foreach my $invalid_patron (@invalid_patrons) {
289
            new_item( sprintf "Patron borrowernumber=%s has an invalid age of %s for their category '%s'",
303
            my $category = $invalid_patron->category;
290
                $patron->borrowernumber, $patron->get_age, $patron->category->categorycode, );
304
            new_item(
305
                sprintf "Patron borrowernumber=%s has an invalid age of %s for their category '%s' (%s-%s)",
306
                $invalid_patron->borrowernumber, $invalid_patron->get_age, $category->categorycode,
307
                $category->dateofbirthrequired,  $category->upperagelimit
308
            );
291
        }
309
        }
292
        new_hint("You may change the patron's category automatically with misc/cronjobs/update_patrons_category.pl");
310
        new_hint("You may change the patron's category automatically with misc/cronjobs/update_patrons_category.pl");
293
    }
311
    }
294
- 

Return to bug 26311