[Koha-patches] [PATCH 2/2] [SIGNED-OFF] Bug 5610: Add --since for setting messaging to default

Nicole C. Engard nengard at bywatersolutions.com
Thu Mar 17 02:02:30 CET 2011


From: Jared Camins-Esakov <jcamins at bywatersolutions.com>

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 at bywatersolutions.com>
Signed-off-by: Nicole C. Engard <nengard at bywatersolutions.com>
---
 .../maintenance/borrowers-force-messaging-defaults |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/misc/maintenance/borrowers-force-messaging-defaults b/misc/maintenance/borrowers-force-messaging-defaults
index 11f2228..ff35e08 100755
--- a/misc/maintenance/borrowers-force-messaging-defaults
+++ b/misc/maintenance/borrowers-force-messaging-defaults
@@ -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
 
-- 
1.7.2.3



More information about the Koha-patches mailing list