Add payment due report
This commit is contained in:
parent
b64a64c015
commit
65e16af4f9
@ -233,10 +233,8 @@ function getChildCareReport(): Report {
|
|||||||
$Strings->get("Count", false)
|
$Strings->get("Count", false)
|
||||||
];
|
];
|
||||||
|
|
||||||
|
|
||||||
$results = $database->select("adults", 'child_care', ["child_care[!]" => null]);
|
$results = $database->select("adults", 'child_care', ["child_care[!]" => null]);
|
||||||
|
|
||||||
|
|
||||||
$report->setHeader($header);
|
$report->setHeader($header);
|
||||||
|
|
||||||
$ages = [];
|
$ages = [];
|
||||||
@ -266,6 +264,47 @@ function getChildCareReport(): Report {
|
|||||||
return $report;
|
return $report;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get a report of the families who still owe money.
|
||||||
|
* @global type $database
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
function getPaymentDueReport(): Report {
|
||||||
|
global $database, $Strings;
|
||||||
|
|
||||||
|
$report = new Report($Strings->get("Payments Due", false));
|
||||||
|
$filter = ["ORDER" => ["familyname" => "ASC"]];
|
||||||
|
|
||||||
|
$join = [];
|
||||||
|
$where = [];
|
||||||
|
|
||||||
|
$header = [
|
||||||
|
$Strings->get("Family", false),
|
||||||
|
$Strings->get("Total", false),
|
||||||
|
$Strings->get("Paid", false),
|
||||||
|
$Strings->get("Due", false),
|
||||||
|
$Strings->get("First Names", false)
|
||||||
|
];
|
||||||
|
|
||||||
|
$payments = $database->select("payments", ['familyid', 'paymentid (id)', 'amount', 'amountpaid']);
|
||||||
|
|
||||||
|
foreach ($payments as $p) {
|
||||||
|
$familynames = $database->select('people', 'lastname', ['familyid' => $p['familyid']]);
|
||||||
|
$firstnames = $database->select('people', 'firstname', ['familyid' => $p['familyid']]);
|
||||||
|
$report->addDataRow([
|
||||||
|
implode(", ", array_unique($familynames)),
|
||||||
|
number_format($p["amount"], 2),
|
||||||
|
number_format($p["amountpaid"], 2),
|
||||||
|
number_format($p["amount"] - $p["amountpaid"], 2),
|
||||||
|
implode(", ", $firstnames)
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$report->setHeader($header);
|
||||||
|
|
||||||
|
return $report;
|
||||||
|
}
|
||||||
|
|
||||||
function getReport($type): Report {
|
function getReport($type): Report {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case "campers":
|
case "campers":
|
||||||
@ -283,6 +322,9 @@ function getReport($type): Report {
|
|||||||
case "childcare":
|
case "childcare":
|
||||||
return getChildCareReport();
|
return getChildCareReport();
|
||||||
break;
|
break;
|
||||||
|
case "paymentsdue":
|
||||||
|
return getPaymentDueReport();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return new Report("error", ["ERROR"], ["Invalid report type."]);
|
return new Report("error", ["ERROR"], ["Invalid report type."]);
|
||||||
}
|
}
|
||||||
|
@ -84,6 +84,20 @@
|
|||||||
<i class="fas fa-file-csv"></i> <?php $Strings->get("CSV"); ?>
|
<i class="fas fa-file-csv"></i> <?php $Strings->get("CSV"); ?>
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</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">
|
||||||
|
<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=paymentsdue&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=paymentsdue&format=csv">
|
||||||
|
<i class="fas fa-file-csv"></i> <?php $Strings->get("CSV"); ?>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
Loading…
x
Reference in New Issue
Block a user