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 54-60
sub force_borrower_messaging_defaults {
Link Here
|
54 |
$dbh->do(q|SET FOREIGN_KEY_CHECKS = 1|); |
54 |
$dbh->do(q|SET FOREIGN_KEY_CHECKS = 1|); |
55 |
} |
55 |
} |
56 |
|
56 |
|
57 |
my $sth = $dbh->prepare("SELECT borrowernumber, categorycode FROM borrowers WHERE dateenrolled >= ?"); |
57 |
my $sql = "SELECT borrowernumber, categorycode FROM borrowers WHERE dateenrolled >= ?"; |
|
|
58 |
if ($actives) { |
59 |
$sql .= " AND dateexpiry > NOW()" |
60 |
} |
61 |
my $sth = $dbh->prepare($sql); |
58 |
$sth->execute($since); |
62 |
$sth->execute($since); |
59 |
while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) { |
63 |
while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) { |
60 |
print "$borrowernumber: $categorycode\n"; |
64 |
print "$borrowernumber: $categorycode\n"; |
Lines 68-84
sub force_borrower_messaging_defaults {
Link Here
|
68 |
} |
72 |
} |
69 |
|
73 |
|
70 |
|
74 |
|
71 |
my ($doit, $truncate, $since, $help); |
75 |
my ($doit, $truncate, $since, $help, $actives); |
72 |
my $result = GetOptions( |
76 |
my $result = GetOptions( |
73 |
'doit' => \$doit, |
77 |
'doit' => \$doit, |
74 |
'truncate' => \$truncate, |
78 |
'truncate' => \$truncate, |
75 |
'since:s' => \$since, |
79 |
'since:s' => \$since, |
76 |
'help|h' => \$help, |
80 |
'actives' => \$actives, |
|
|
81 |
'help|h' => \$help, |
77 |
); |
82 |
); |
78 |
|
83 |
|
79 |
usage() if $help; |
84 |
usage() if $help; |
80 |
|
85 |
|
81 |
force_borrower_messaging_defaults( $doit, $truncate, $since ); |
86 |
force_borrower_messaging_defaults( $doit, $truncate, $since, $actives ); |
82 |
|
87 |
|
83 |
=head1 NAME |
88 |
=head1 NAME |
84 |
|
89 |
|
Lines 90-95
force-borrower-messaging-defaults
Link Here
|
90 |
force-borrower-messaging-defaults --help |
95 |
force-borrower-messaging-defaults --help |
91 |
force-borrower-messaging-defaults --doit |
96 |
force-borrower-messaging-defaults --doit |
92 |
force-borrower-messaging-defaults --doit --truncate |
97 |
force-borrower-messaging-defaults --doit --truncate |
|
|
98 |
force-borrower-messaging-defaults --doit --actives |
93 |
|
99 |
|
94 |
=head1 DESCRIPTION |
100 |
=head1 DESCRIPTION |
95 |
|
101 |
|
Lines 110-122
Prints this help
Link Here
|
110 |
|
116 |
|
111 |
=item B<--doit> |
117 |
=item B<--doit> |
112 |
|
118 |
|
113 |
Process actually the borrowers. |
119 |
Actually update the borrowers. |
114 |
|
120 |
|
115 |
=item B<--truncate> |
121 |
=item B<--truncate> |
116 |
|
122 |
|
117 |
Truncate all borrowers transport preferences before (re-)creating them. It |
123 |
Truncate all borrowers transport preferences before (re-)creating them. It |
118 |
affects borrower_message_preferences table. |
124 |
affects borrower_message_preferences table. |
119 |
|
125 |
|
|
|
126 |
=item B<--actives> |
127 |
|
128 |
Will only update active borrowers (borrowers who didn't pass their expiration date). |
129 |
|
120 |
=back |
130 |
=back |
121 |
|
131 |
|
122 |
=cut |
132 |
=cut |
123 |
- |
|
|