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

(-)a/misc/maintenance/borrowers-force-messaging-defaults (-9 / +13 lines)
Lines 39-45 sub usage { Link Here
39
39
40
40
41
sub force_borrower_messaging_defaults {
41
sub force_borrower_messaging_defaults {
42
    my ($doit, $truncate, $since) = @_;
42
    my ($doit, $truncate, $since, $onlyactives) = @_;
43
43
44
    $since = '0000-00-00' if (!$since);
44
    $since = '0000-00-00' if (!$since);
45
    print $since;
45
    print $since;
Lines 52-58 sub force_borrower_messaging_defaults { Link Here
52
        $sth->execute();
52
        $sth->execute();
53
    }
53
    }
54
54
55
    my $sth = $dbh->prepare("SELECT borrowernumber, categorycode FROM borrowers WHERE dateenrolled >= ?");
55
    my $sql = "SELECT borrowernumber, categorycode FROM borrowers WHERE dateenrolled >= ?";
56
    if ($onlyactives) {
57
        $sql .= " AND dateexpiry > NOW()"
58
    }
59
    my $sth = $dbh->prepare($sql);
56
    $sth->execute($since);
60
    $sth->execute($since);
57
    while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) {
61
    while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) {
58
        print "$borrowernumber: $categorycode\n";
62
        print "$borrowernumber: $categorycode\n";
Lines 66-82 sub force_borrower_messaging_defaults { Link Here
66
}
70
}
67
71
68
72
69
my ($doit, $truncate, $since, $help);
73
my ($doit, $truncate, $since, $help, $onlyactives);
70
my $result = GetOptions(
74
my $result = GetOptions(
71
    'doit'     => \$doit,
75
    'doit'        => \$doit,
72
    'truncate' => \$truncate,
76
    'truncate'    => \$truncate,
73
    'since:s'  => \$since,
77
    'since:s'     => \$since,
74
    'help|h'   => \$help,
78
    'onlyactives' => \$onlyactives,
79
    'help|h'      => \$help,
75
);
80
);
76
81
77
usage() if $help;
82
usage() if $help;
78
83
79
force_borrower_messaging_defaults( $doit, $truncate, $since );
84
force_borrower_messaging_defaults( $doit, $truncate, $since, $onlyactives );
80
85
81
=head1 NAME
86
=head1 NAME
82
87
83
- 

Return to bug 13572