Lines 54-65
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 $sql = "SELECT borrowernumber, categorycode FROM borrowers bo WHERE dateenrolled >= ?"; |
57 |
my $sql = |
|
|
58 |
q|SELECT DISTINCT bo.borrowernumber, bo.categorycode FROM borrowers bo |
59 |
LEFT JOIN borrower_message_preferences mp USING (borrowernumber) |
60 |
WHERE bo.dateenrolled >= ?|; |
58 |
if ($not_expired) { |
61 |
if ($not_expired) { |
59 |
$sql .= " AND dateexpiry >= NOW()" |
62 |
$sql .= " AND bo.dateexpiry >= NOW()" |
60 |
} |
63 |
} |
61 |
if( $no_overwrite ) { |
64 |
if( $no_overwrite ) { |
62 |
$sql .= " AND (SELECT COUNT(*) FROM borrower_message_preferences mp WHERE mp.borrowernumber=bo.borrowernumber) = 0" |
65 |
$sql .= " AND mp.borrowernumber IS NULL"; |
63 |
} |
66 |
} |
64 |
my $sth = $dbh->prepare($sql); |
67 |
my $sth = $dbh->prepare($sql); |
65 |
$sth->execute($since); |
68 |
$sth->execute($since); |
66 |
- |
|
|