This fix GetBorrowersWhoHaveNotBorrowedSince to select only borrowers that have 
no issues and have no old_issues more recent than a specified date.
---
 C4/Members.pm |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/C4/Members.pm b/C4/Members.pm
index f5a360e..43305c5 100644
--- a/C4/Members.pm
+++ b/C4/Members.pm
@@ -1756,7 +1756,7 @@ Looks up the different title . Returns array  with all 
borrowers title
 =cut
 
 sub GetTitles {
-    my @borrowerTitle = split 
/,|\|/,C4::Context->preference('BorrowersTitles');
+    my @borrowerTitle = split 
(/,|\|/,C4::Context->preference('BorrowersTitles'));
     unshift( @borrowerTitle, "" );
     my $cou...@borrowertitle;
     if ($count == 1){
@@ -1870,10 +1870,13 @@ sub GetBorrowersWhoHaveNotBorrowedSince {
                          : "");  
     my $dbh   = C4::Context->dbh;
     my $query = "
-        SELECT borrowers.borrowernumber,max(issues.timestamp) as latestissue
+        SELECT borrowers.borrowernumber,
+               max(old_issues.timestamp) as latestissue,
+               max(issues.timestamp) as currentissue
         FROM   borrowers
         JOIN   categories USING (categorycode)
-        LEFT JOIN issues ON borrowers.borrowernumber = issues.borrowernumber
+        LEFT JOIN old_issues USING (borrowernumber)
+        LEFT JOIN issues USING (borrowernumber) 
         WHERE  category_type <> 'S'
    ";
     my @query_params;
@@ -1886,7 +1889,8 @@ sub GetBorrowersWhoHaveNotBorrowedSince {
     }
     $query.=" GROUP BY borrowers.borrowernumber";
     if ($filterdate){ 
-        $query.=" HAVING latestissue <? OR latestissue IS NULL";
+        $query.=" HAVING (latestissue < ? OR latestissue IS NULL) 
+                  AND currentissue IS NULL";
         push @query_params,$filterdate;
     }
     warn $query if $debug;
-- 
1.6.3.3

_______________________________________________
Koha-patches mailing list
[email protected]
http://lists.koha.org/mailman/listinfo/koha-patches

Reply via email to