Lines 42-49
sub usage {
Link Here
|
42 |
sub force_borrower_messaging_defaults { |
42 |
sub force_borrower_messaging_defaults { |
43 |
my ($doit, $since, $not_expired, $no_overwrite, $category ) = @_; |
43 |
my ($doit, $since, $not_expired, $no_overwrite, $category ) = @_; |
44 |
|
44 |
|
45 |
$since = '0000-00-00' if (!$since); |
45 |
print "Since: $since\n" if $since; |
46 |
print "Since: $since\n"; |
|
|
47 |
|
46 |
|
48 |
my $dbh = C4::Context->dbh; |
47 |
my $dbh = C4::Context->dbh; |
49 |
$dbh->{AutoCommit} = 0; |
48 |
$dbh->{AutoCommit} = 0; |
Lines 51-57
sub force_borrower_messaging_defaults {
Link Here
|
51 |
my $sql = |
50 |
my $sql = |
52 |
q|SELECT DISTINCT bo.borrowernumber, bo.categorycode FROM borrowers bo |
51 |
q|SELECT DISTINCT bo.borrowernumber, bo.categorycode FROM borrowers bo |
53 |
LEFT JOIN borrower_message_preferences mp USING (borrowernumber) |
52 |
LEFT JOIN borrower_message_preferences mp USING (borrowernumber) |
54 |
WHERE bo.dateenrolled >= ?|; |
53 |
WHERE 1| |
|
|
54 |
if ( $since ) { |
55 |
$sql .= " AND bo.dateenrolled >= ?"; |
56 |
} |
55 |
if ($not_expired) { |
57 |
if ($not_expired) { |
56 |
$sql .= " AND bo.dateexpiry >= NOW()" |
58 |
$sql .= " AND bo.dateexpiry >= NOW()" |
57 |
} |
59 |
} |
Lines 60-66
WHERE bo.dateenrolled >= ?|;
Link Here
|
60 |
} |
62 |
} |
61 |
$sql .= " AND bo.categorycode = ?" if $category; |
63 |
$sql .= " AND bo.categorycode = ?" if $category; |
62 |
my $sth = $dbh->prepare($sql); |
64 |
my $sth = $dbh->prepare($sql); |
63 |
$sth->execute($since, $category || () ); |
65 |
$sth->execute($since || (), $category || () ); |
64 |
my $cnt = 0; |
66 |
my $cnt = 0; |
65 |
while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) { |
67 |
while ( my ($borrowernumber, $categorycode) = $sth->fetchrow ) { |
66 |
print "$borrowernumber: $categorycode\n"; |
68 |
print "$borrowernumber: $categorycode\n"; |
67 |
- |
|
|