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

(-)a/misc/cronjobs/fix_invalid_dates.pl (+58 lines)
Line 0 Link Here
1
#!/usr/bin/perl
2
 
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
 
18
use Modern::Perl;
19
 
20
use C4::Context;
21
use C4::Log qw(cronlogaction);
22
use Getopt::Long qw( GetOptions );
23
use Pod::Usage qw( pod2usage );
24
use Koha::Logger;
25
use Koha::Patrons;
26
use Koha::DateUtils qw( dt_from_string );
27
use Koha::Script -cron;
28
use Data::Dumper;
29
 
30
my $verbose = 0;
31
my $doit = 0;
32
 
33
GetOptions(
34
    'v|verbose'       => \$verbose,
35
    'c|confirm'       => \$doit,
36
);
37
38
my $count = 0;
39
 
40
# search patrons that have date fields that are 0000-00-00
41
foreach my $date_type (qw(dateofbirth dateenrolled dateexpiry date_renewed lastseen updated_on debarred)) {
42
    my $borrowers = Koha::Patrons->search( { $date_type=>'0000-00-00' } );
43
 
44
        while (my $borrower = $borrowers->next()) {
45
            $count++;
46
            if ($doit) { # if confirm flag was run with cronjob
47
                $borrower->$date_type(undef)->store();
48
            }
49
        }
50
51
}
52
53
if ($verbose) {
54
  print "$count invalid dates found\n";
55
  if ($doit) {
56
    print "$count invalid dates fixed\n"
57
  }
58
}
(-)a/misc/maintenance/search_for_data_inconsistencies.pl (-1 / +20 lines)
Lines 326-331 use C4::Biblio qw( GetMarcFromKohaField ); Link Here
326
    }
326
    }
327
}
327
}
328
328
329
{
330
    my $count = 0;
331
332
    # search patrons that have date fields that are 0000-00-00
333
    foreach my $date_type (qw(dateofbirth dateenrolled dateexpiry date_renewed lastseen updated_on debarred)) {
334
        my $borrowers = Koha::Patrons->search( { $date_type=>'0000-00-00' } );
335
        while (my $borrower = $borrowers->next()) {
336
            $count++;
337
        }
338
    }
339
340
    new_section("$count invalid dates found");
341
342
    if ($count > 0) {
343
        new_hint("You may change the date with script: misc/cronjobs/fix_invalid_dates.pl (-c -v)");
344
    }
345
346
}
347
329
{
348
{
330
    my @loop_borrowers_relationships;
349
    my @loop_borrowers_relationships;
331
    my @guarantor_ids = Koha::Patron::Relationships->_resultset->get_column('guarantor_id')->all();
350
    my @guarantor_ids = Koha::Patron::Relationships->_resultset->get_column('guarantor_id')->all();
Lines 450-454 Catch data inconsistencies in Koha database Link Here
450
  * Item types defined in items or biblioitems must be defined in the itemtypes table
469
  * Item types defined in items or biblioitems must be defined in the itemtypes table
451
* Invalid MARCXML in bibliographic records
470
* Invalid MARCXML in bibliographic records
452
* Patrons with invalid category types due to lower and upper age limits
471
* Patrons with invalid category types due to lower and upper age limits
472
* Patrons with 0000-00-00 dates in fields dateofbirth, dateenrolled, dateexpiry, date_renewed, lastseen, updated_on, debarred
453
473
454
=cut
474
=cut
455
- 

Return to bug 31143