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

(-)a/misc/maintenance/search_for_data_inconsistencies.pl (-7 / +25 lines)
Lines 216-231 use C4::Biblio; Link Here
216
}
216
}
217
217
218
{
218
{
219
    my $patrons = Koha::Patrons->search( {}, { order_by => [ 'categorycode', 'borrowernumber' ] } );
219
    my $aging_patrons = Koha::Patrons->search(
220
        {
221
            -not => {
222
                -or => {
223
                    'me.dateofbirth' => undef,
224
                    -and => {
225
                        'categorycode.dateofbirthrequired' => undef,
226
                        'categorycode.upperagelimit'       => undef,
227
                    }
228
                }
229
            }
230
        },
231
        { join     => { 'categorycode' => 'borrowers' } },
232
        { order_by => [ 'me.categorycode', 'me.borrowernumber' ] },
233
    );
220
    my @invalid_patrons;
234
    my @invalid_patrons;
221
    while ( my $patron = $patrons->next ) {
235
    while ( my $aging_patron = $aging_patrons->next ) {
222
        push @invalid_patrons, $patron unless $patron->is_valid_age;
236
        warn $aging_patron->borrowernumber;
237
        push @invalid_patrons, $aging_patron unless $aging_patron->is_valid_age;
223
    }
238
    }
224
    if (@invalid_patrons) {
239
    if (@invalid_patrons) {
225
        new_section("Patrons with invalid age for category");
240
        new_section("Patrons with invalid age for category");
226
        foreach my $patron (@invalid_patrons) {
241
        foreach my $invalid_patron (@invalid_patrons) {
227
            new_item( sprintf "Patron borrowernumber=%s has an invalid age of %s for their category '%s'",
242
            my $category = $invalid_patron->category;
228
                $patron->borrowernumber, $patron->get_age, $patron->category->categorycode, );
243
            new_item(
244
                sprintf "Patron borrowernumber=%s has an invalid age of %s for their category '%s' (%s-%s)",
245
                $invalid_patron->borrowernumber, $invalid_patron->get_age, $category->categorycode,
246
                $category->dateofbirthrequired,  $category->upperagelimit
247
            );
229
        }
248
        }
230
        new_hint("You may change the patron's category automatically with misc/cronjobs/update_patrons_category.pl");
249
        new_hint("You may change the patron's category automatically with misc/cronjobs/update_patrons_category.pl");
231
    }
250
    }
232
- 

Return to bug 26311