|
|
|
@ -29,7 +29,7 @@ if (LOADED) {
|
|
|
|
|
/**
|
|
|
|
|
* Get a 2d array of the families in the database.
|
|
|
|
|
* @global type $database
|
|
|
|
|
* @param array $filter Medoo WHERE clause.
|
|
|
|
|
* @param string $filter
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
function getPeopleReport($filter = ""): Report {
|
|
|
|
@ -80,6 +80,7 @@ function getPeopleReport($filter = ""): Report {
|
|
|
|
|
$Strings->get("Position", false),
|
|
|
|
|
$Strings->get("Shirt", false),
|
|
|
|
|
$Strings->get("Sex", false),
|
|
|
|
|
$Strings->get("Child Care Ages", false),
|
|
|
|
|
$Strings->get("Notes", false)
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
@ -168,6 +169,7 @@ function getPeopleReport($filter = ""): Report {
|
|
|
|
|
$p['position'],
|
|
|
|
|
$p['shirt'],
|
|
|
|
|
$p['sex'],
|
|
|
|
|
$p['child_care'],
|
|
|
|
|
$p['notes']
|
|
|
|
|
];
|
|
|
|
|
break;
|
|
|
|
@ -208,6 +210,62 @@ function getPeopleReport($filter = ""): Report {
|
|
|
|
|
return $report;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a report of the children who need child care.
|
|
|
|
|
* @global type $database
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
|
|
|
|
function getChildCareReport(): Report {
|
|
|
|
|
global $database, $Strings;
|
|
|
|
|
|
|
|
|
|
if (empty($filter)) {
|
|
|
|
|
$report = new Report($Strings->get("Child Care Ages", false));
|
|
|
|
|
$filter = ["ORDER" => ["familyname" => "ASC"]];
|
|
|
|
|
} else {
|
|
|
|
|
$report = new Report($Strings->get("$filter", false));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$join = [];
|
|
|
|
|
$where = [];
|
|
|
|
|
|
|
|
|
|
$header = [
|
|
|
|
|
$Strings->get("Age", false),
|
|
|
|
|
$Strings->get("Count", false)
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$results = $database->select("adults", 'child_care', ["child_care[!]" => null]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$report->setHeader($header);
|
|
|
|
|
|
|
|
|
|
$ages = [];
|
|
|
|
|
|
|
|
|
|
$totalcount = 0;
|
|
|
|
|
|
|
|
|
|
foreach ($results as $r) {
|
|
|
|
|
$items = preg_split("/[^\d]+/", $r);
|
|
|
|
|
foreach ($items as $it) {
|
|
|
|
|
if (!isset($ages[$it])) {
|
|
|
|
|
$ages[$it] = 1;
|
|
|
|
|
} else {
|
|
|
|
|
$ages[$it]++;
|
|
|
|
|
}
|
|
|
|
|
$totalcount++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
ksort($ages);
|
|
|
|
|
|
|
|
|
|
foreach ($ages as $age => $count) {
|
|
|
|
|
$report->addDataRow(["$age", "$count"]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$report->addDataRow([$Strings->get("Total", false), "$totalcount"]);
|
|
|
|
|
|
|
|
|
|
return $report;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getReport($type): Report {
|
|
|
|
|
switch ($type) {
|
|
|
|
|
case "campers":
|
|
|
|
@ -222,6 +280,9 @@ function getReport($type): Report {
|
|
|
|
|
case "people":
|
|
|
|
|
return getPeopleReport("");
|
|
|
|
|
break;
|
|
|
|
|
case "childcare":
|
|
|
|
|
return getChildCareReport();
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
return new Report("error", ["ERROR"], ["Invalid report type."]);
|
|
|
|
|
}
|
|
|
|
|