Bug 5610: Add --since for setting messaging to default

It is now possible to specify a command line argument --since so that the
borrowers-force-messaging-defaults script only changes patrons created starting
on a certain day. If the optional argument is not specified, the script applies
to all borrowers.

Signed-off-by: Jared Camins-Esakov <jcamins@bywatersolutions.com>
Signed-off-by: Nicole C. Engard <nengard@bywatersolutions.com>
Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
This commit is contained in:
Jared Camins-Esakov 2011-03-16 21:02:30 -04:00 committed by Chris Cormack
parent 662175571e
commit e158f86d20

View file

@ -39,7 +39,10 @@ sub usage {
sub force_borrower_messaging_defaults {
my ($doit, $truncate) = @_;
my ($doit, $truncate, $since) = @_;
$since = '0000-00-00' if (!$since);
print $since;
my $dbh = C4::Context->dbh;
$dbh->{AutoCommit} = 0;
@ -49,8 +52,8 @@ sub force_borrower_messaging_defaults {
$sth->execute();
}
my $sth = $dbh->prepare("SELECT borrowernumber, categorycode FROM borrowers");
$sth->execute();
my $sth = $dbh->prepare("SELECT borrowernumber, categorycode FROM borrowers WHERE dateenrolled >= ?");
$sth->execute($since);
while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) {
print "$borrowernumber: $categorycode\n";
next unless $doit;
@ -63,16 +66,17 @@ sub force_borrower_messaging_defaults {
}
my ($doit, $truncate, $help);
my ($doit, $truncate, $since, $help);
my $result = GetOptions(
'doit' => \$doit,
'truncate' => \$truncate,
'since:s' => \$since,
'help|h' => \$help,
);
usage() if $help;
force_borrower_messaging_defaults( $doit, $truncate);
force_borrower_messaging_defaults( $doit, $truncate, $since );
=head1 NAME