|
Lines 73-79
BEGIN {
Link Here
|
| 73 |
&GetBorNotifyAcctRecord |
73 |
&GetBorNotifyAcctRecord |
| 74 |
|
74 |
|
| 75 |
&GetBorrowersToExpunge |
75 |
&GetBorrowersToExpunge |
| 76 |
&GetBorrowersWhoHaveNeverBorrowed |
|
|
| 77 |
&GetBorrowersWithIssuesHistoryOlderThan |
76 |
&GetBorrowersWithIssuesHistoryOlderThan |
| 78 |
|
77 |
|
| 79 |
&GetUpcomingMembershipExpires |
78 |
&GetUpcomingMembershipExpires |
|
Lines 1200-1252
sub GetBorrowersToExpunge {
Link Here
|
| 1200 |
return \@results; |
1199 |
return \@results; |
| 1201 |
} |
1200 |
} |
| 1202 |
|
1201 |
|
| 1203 |
=head2 GetBorrowersWhoHaveNeverBorrowed |
|
|
| 1204 |
|
| 1205 |
$results = &GetBorrowersWhoHaveNeverBorrowed |
| 1206 |
|
| 1207 |
This function get all borrowers who have never borrowed. |
| 1208 |
|
| 1209 |
I<$result> is a ref to an array which all elements are a hasref. |
| 1210 |
|
| 1211 |
=cut |
| 1212 |
|
| 1213 |
sub GetBorrowersWhoHaveNeverBorrowed { |
| 1214 |
my $filterbranch = shift || |
| 1215 |
((C4::Context->preference('IndependentBranches') |
| 1216 |
&& C4::Context->userenv |
| 1217 |
&& !C4::Context->IsSuperLibrarian() |
| 1218 |
&& C4::Context->userenv->{branch}) |
| 1219 |
? C4::Context->userenv->{branch} |
| 1220 |
: ""); |
| 1221 |
my $dbh = C4::Context->dbh; |
| 1222 |
my $query = " |
| 1223 |
SELECT borrowers.borrowernumber,max(timestamp) as latestissue |
| 1224 |
FROM borrowers |
| 1225 |
LEFT JOIN issues ON borrowers.borrowernumber = issues.borrowernumber |
| 1226 |
WHERE issues.borrowernumber IS NULL |
| 1227 |
"; |
| 1228 |
my @query_params; |
| 1229 |
if ($filterbranch && $filterbranch ne ""){ |
| 1230 |
$query.=" AND borrowers.branchcode= ?"; |
| 1231 |
push @query_params,$filterbranch; |
| 1232 |
} |
| 1233 |
warn $query if $debug; |
| 1234 |
|
| 1235 |
my $sth = $dbh->prepare($query); |
| 1236 |
if (scalar(@query_params)>0){ |
| 1237 |
$sth->execute(@query_params); |
| 1238 |
} |
| 1239 |
else { |
| 1240 |
$sth->execute; |
| 1241 |
} |
| 1242 |
|
| 1243 |
my @results; |
| 1244 |
while ( my $data = $sth->fetchrow_hashref ) { |
| 1245 |
push @results, $data; |
| 1246 |
} |
| 1247 |
return \@results; |
| 1248 |
} |
| 1249 |
|
| 1250 |
=head2 GetBorrowersWithIssuesHistoryOlderThan |
1202 |
=head2 GetBorrowersWithIssuesHistoryOlderThan |
| 1251 |
|
1203 |
|
| 1252 |
$results = &GetBorrowersWithIssuesHistoryOlderThan($date) |
1204 |
$results = &GetBorrowersWithIssuesHistoryOlderThan($date) |