diff --git a/lib/reports.php b/lib/reports.php index 7709581..faa2c86 100644 --- a/lib/reports.php +++ b/lib/reports.php @@ -269,10 +269,10 @@ function getChildCareReport(): Report { * @global type $database * @return string */ -function getPaymentDueReport(): Report { +function getPaymentReport($filter = ""): Report { global $database, $Strings; - $report = new Report($Strings->get("Payments Due", false)); + $report = new Report($Strings->get("Payments" . ($filter == "due" ? " Due" : ""), false)); $filter = ["ORDER" => ["familyname" => "ASC"]]; $join = []; @@ -289,8 +289,14 @@ function getPaymentDueReport(): Report { $payments = $database->select("payments", ['familyid', 'paymentid (id)', 'amount', 'amountpaid']); foreach ($payments as $p) { + if ($filter == "due" && $p["amount"] - $p["amountpaid"] <= 0) { + continue; + } $familynames = $database->select('people', 'lastname', ['familyid' => $p['familyid']]); $firstnames = $database->select('people', 'firstname', ['familyid' => $p['familyid']]); + if (count($familynames) == 0 && $p["amount"] == 0 && $p["amountpaid"] == 0) { + continue; + } $report->addDataRow([ implode(", ", array_unique($familynames)), number_format($p["amount"], 2), @@ -322,8 +328,11 @@ function getReport($type): Report { case "childcare": return getChildCareReport(); break; + case "payments": + return getPaymentReport(); + break; case "paymentsdue": - return getPaymentDueReport(); + return getPaymentReport("due"); break; default: return new Report("error", ["ERROR"], ["Invalid report type."]); diff --git a/pages/reports.php b/pages/reports.php index 8e55dc1..81f4fa2 100644 --- a/pages/reports.php +++ b/pages/reports.php @@ -85,6 +85,20 @@ +
+

get("Payments"); ?>

+ + get("Spreadsheet (ODS)"); ?> + +
+ + get("HTML"); ?> + + + get("CSV"); ?> + +
+

get("Payments Still Due"); ?>