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

(-)a/misc/maintenance/borrowers-force-messaging-defaults (-10 / +19 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, $actives) = @_;
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 ($actives) {
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, $actives);
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
    'actives'     => \$actives,
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, $actives );
80
85
81
=head1 NAME
86
=head1 NAME
82
87
Lines 88-93 force-borrower-messaging-defaults Link Here
88
  force-borrower-messaging-defaults --help
93
  force-borrower-messaging-defaults --help
89
  force-borrower-messaging-defaults --doit
94
  force-borrower-messaging-defaults --doit
90
  force-borrower-messaging-defaults --doit --truncate
95
  force-borrower-messaging-defaults --doit --truncate
96
  force-borrower-messaging-defaults --doit --actives
91
97
92
=head1 DESCRIPTION
98
=head1 DESCRIPTION
93
99
Lines 108-120 Prints this help Link Here
108
114
109
=item B<--doit>
115
=item B<--doit>
110
116
111
Process actually the borrowers.
117
Actually update the borrowers.
112
118
113
=item B<--truncate>
119
=item B<--truncate>
114
120
115
Truncate all borrowers transport preferences before (re-)creating them. It
121
Truncate all borrowers transport preferences before (re-)creating them. It
116
affects borrower_message_preferences table.
122
affects borrower_message_preferences table.
117
123
124
=item B<--actives>
125
126
Will only update active borrowers (borrowers who didn't pass their expiration date).
127
118
=back
128
=back
119
129
120
=cut
130
=cut
121
- 

Return to bug 13572