- $strcalc .= "SELECT CONCAT( borrowers.surname , \"\\t\",borrowers.firstname, \"\\t\", borrowers.cardnumber)";
- $strcalc .= " , $colfield " if ($colfield);
- $strcalc .= " FROM borrowers ";
- $strcalc .= "WHERE 1 ";
- @$filters[0]=~ s/\*/%/g if (@$filters[0]);
- $strcalc .= " AND borrowers.categorycode like '" . @$filters[0] ."'" if ( @$filters[0] );
- if (@$filters[1]){
- my $strqueryfilter="SELECT DISTINCT borrowernumber FROM issues where issues.timestamp> @$filters[1] ";
- my $queryfilter = $dbh->prepare("SELECT DISTINCT borrowernumber FROM issues where issues.timestamp> @$filters[1] ");
- $strcalc .= " AND borrowers.borrowernumber not in ($strqueryfilter)";
-
-# $queryfilter->execute(@$filters[1]);
-# while (my ($borrowernumber)=$queryfilter->fetchrow){
-# $strcalc .= " AND borrowers.borrowernumber <> $borrowernumber ";
-# }
- } else {
- my $strqueryfilter="SELECT DISTINCT borrowernumber FROM issues ";
- my $queryfilter = $dbh->prepare("SELECT DISTINCT borrowernumber FROM issues ");
- $queryfilter->execute;
- $strcalc .= " AND borrowers.borrowernumber not in ($strqueryfilter)";
-# while (my ($borrowernumber)=$queryfilter->fetchrow){
-# $strcalc .= " AND borrowers.borrowernumber <> $borrowernumber ";
-# }
- }
- $strcalc .= " group by borrowers.borrowernumber";
- $strcalc .= ", $colfield" if ($column);
- $strcalc .= " order by $colfield " if ($colfield);
- my $max;
- if (@loopcol) {
- $max = $line*@loopcol;
- } else { $max=$line;}
- $strcalc .= " LIMIT 0,$max" if ($line);
- warn "SQL :". $strcalc;
-
- my $dbcalc = $dbh->prepare($strcalc);
- $dbcalc->execute;
+ $strcalc .= "SELECT CONCAT( borrowers.surname , \"\\t\",borrowers.firstname, \"\\t\", borrowers.cardnumber)";
+ $strcalc .= " , $colfield " if ($colfield);
+ $strcalc .= " FROM borrowers ";
+ $strcalc .= "WHERE 1 ";
+ @$filters[0]=~ s/\*/%/g if (@$filters[0]);
+ $strcalc .= " AND borrowers.categorycode like '" . @$filters[0] ."'" if ( @$filters[0] );
+ my $strqueryfilter = "SELECT DISTINCT borrowernumber FROM old_issues WHERE borrowernumber IS NOT NULL ";
+ if (@$filters[1]){
+ my $strqueryfilter .= "AND old_issues.timestamp> @$filters[1] ";
+ }
+ $strcalc .= " AND borrowers.borrowernumber not in ($strqueryfilter)";
+ $strcalc .= " group by borrowers.borrowernumber";
+ $strcalc .= ", $colfield" if ($column);
+ $strcalc .= " order by $colfield " if ($colfield);
+ my $max;
+ if ($line) {
+ if (@loopcol) {
+ $max = $line*@loopcol;
+ } else { $max=$line;}
+ $strcalc .= " LIMIT 0,$max";
+ }
+
+ my $dbcalc = $dbh->prepare($strcalc);
+ $dbcalc->execute;