Add payments report
This commit is contained in:
parent
65e16af4f9
commit
d801dd4fa8
@ -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."]);
|
||||
|
@ -85,6 +85,20 @@
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3 mb-4">
|
||||
<h4><?php $Strings->get("Payments"); ?></h4>
|
||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=payments&format=ods">
|
||||
<i class="fas fa-table"></i> <?php $Strings->get("Spreadsheet (ODS)"); ?>
|
||||
</a>
|
||||
<br />
|
||||
<a class="btn btn-orange btn-sm mr-1" href="./lib/reports.php?type=payments&format=html">
|
||||
<i class="fab fa-html5"></i> <?php $Strings->get("HTML"); ?>
|
||||
</a>
|
||||
<a class="btn btn-secondary btn-sm" href="./lib/reports.php?type=payments&format=csv">
|
||||
<i class="fas fa-file-csv"></i> <?php $Strings->get("CSV"); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3 mb-4">
|
||||
<h4><?php $Strings->get("Payments Still Due"); ?></h4>
|
||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=paymentsdue&format=ods">
|
||||
|
Loading…
x
Reference in New Issue
Block a user