Lines 2111-2127
sub GetBorrowersToExpunge {
Link Here
|
2111 |
: ""); |
2111 |
: ""); |
2112 |
|
2112 |
|
2113 |
my $dbh = C4::Context->dbh; |
2113 |
my $dbh = C4::Context->dbh; |
2114 |
my $query = " |
2114 |
my $query = q| |
2115 |
SELECT borrowers.borrowernumber, |
2115 |
SELECT borrowers.borrowernumber, |
2116 |
MAX(old_issues.timestamp) AS latestissue, |
2116 |
MAX(old_issues.timestamp) AS latestissue, |
2117 |
MAX(issues.timestamp) AS currentissue |
2117 |
MAX(issues.timestamp) AS currentissue |
2118 |
FROM borrowers |
2118 |
FROM borrowers |
2119 |
JOIN categories USING (categorycode) |
2119 |
JOIN categories USING (categorycode) |
|
|
2120 |
LEFT JOIN ( |
2121 |
SELECT guarantorid |
2122 |
FROM borrowers |
2123 |
WHERE guarantorid IS NOT NULL |
2124 |
AND guarantorid <> 0 |
2125 |
) as tmp ON borrowers.borrowernumber=tmp.guarantorid |
2120 |
LEFT JOIN old_issues USING (borrowernumber) |
2126 |
LEFT JOIN old_issues USING (borrowernumber) |
2121 |
LEFT JOIN issues USING (borrowernumber) |
2127 |
LEFT JOIN issues USING (borrowernumber) |
2122 |
WHERE category_type <> 'S' |
2128 |
WHERE category_type <> 'S' |
2123 |
AND borrowernumber NOT IN (SELECT guarantorid FROM borrowers WHERE guarantorid IS NOT NULL AND guarantorid <> 0) |
2129 |
AND tmp.guarantorid IS NOT NULL |
2124 |
"; |
2130 |
|; |
|
|
2131 |
|
2125 |
my @query_params; |
2132 |
my @query_params; |
2126 |
if ( $filterbranch && $filterbranch ne "" ) { |
2133 |
if ( $filterbranch && $filterbranch ne "" ) { |
2127 |
$query.= " AND borrowers.branchcode = ? "; |
2134 |
$query.= " AND borrowers.branchcode = ? "; |
2128 |
- |
|
|