Add reports
This commit is contained in:
parent
628366379b
commit
2b38c39dda
@ -7,8 +7,12 @@
|
||||
"Adult": "Adult",
|
||||
"Adults": "Adults",
|
||||
"Youth": "Youth",
|
||||
"Days": "Days",
|
||||
"Position": "Position",
|
||||
"Parent Phone": "Parent Phone",
|
||||
"Total Income": "Total Income",
|
||||
"Card Payments": "Card Payments",
|
||||
"Camp Coupon/Scout Bucks": "Camp Coupon/Scout Bucks",
|
||||
"First": "First",
|
||||
"Last": "Last",
|
||||
"Last Name": "Last Name",
|
||||
|
File diff suppressed because one or more lines are too long
210
lib/reports.php
210
lib/reports.php
@ -32,85 +32,183 @@ if (LOADED) {
|
||||
* @param array $filter Medoo WHERE clause.
|
||||
* @return string
|
||||
*/
|
||||
function getMemberReport($filter = []): Report {
|
||||
function getPeopleReport($filter = ""): Report {
|
||||
global $database, $Strings;
|
||||
|
||||
if (empty($filter)) {
|
||||
$report = new Report($Strings->get("Families", false));
|
||||
$report = new Report($Strings->get("People", false));
|
||||
$filter = ["ORDER" => ["familyname" => "ASC"]];
|
||||
} else {
|
||||
$report = new Report($Strings->get("Expiring Memberships", false));
|
||||
$report = new Report($Strings->get("$filter", false));
|
||||
}
|
||||
|
||||
$familyids = $database->select(
|
||||
"families", "familyid", $filter
|
||||
);
|
||||
|
||||
$report->setHeader([
|
||||
$Strings->get("Name", false),
|
||||
$Strings->get("Father", false),
|
||||
$Strings->get("Mother", false),
|
||||
$join = [];
|
||||
$where = [];
|
||||
$header = [];
|
||||
switch ($filter) {
|
||||
case "Campers":
|
||||
$join = ["[>]campers" => ["camperid" => "camperid"]];
|
||||
$where = ["people.camperid[!]" => null];
|
||||
$header = [
|
||||
$Strings->get("First", false),
|
||||
$Strings->get("Last", false),
|
||||
$Strings->get("Parent", false),
|
||||
$Strings->get("Unit", false),
|
||||
$Strings->get("Rank", false),
|
||||
$Strings->get("Phone", false),
|
||||
$Strings->get("Email", false),
|
||||
$Strings->get("Address", false),
|
||||
$Strings->get("City", false),
|
||||
$Strings->get("State", false),
|
||||
$Strings->get("ZIP", false),
|
||||
$Strings->get("Photo Permission", false),
|
||||
$Strings->get("Newsletter", false),
|
||||
$Strings->get("Expires", false),
|
||||
$Strings->get("Private", false),
|
||||
$Strings->get("Children", false),
|
||||
]);
|
||||
$families = [];
|
||||
foreach ($familyids as $id) {
|
||||
$f = (new Family())->load($id);
|
||||
$families[] = $f;
|
||||
}
|
||||
foreach ($families as $f) {
|
||||
$newsletter = "";
|
||||
switch ($f->getNewsletter()) {
|
||||
case 1:
|
||||
$newsletter = $Strings->get("Email", false);
|
||||
$Strings->get("Shirt", false),
|
||||
$Strings->get("Sex", false)
|
||||
];
|
||||
break;
|
||||
case 2:
|
||||
$newsletter = $Strings->get("Print", false);
|
||||
case "Adults":
|
||||
$join = ["[>]adults" => ["adultid" => "adultid"]];
|
||||
$where = ["people.adultid[!]" => null];
|
||||
$header = [
|
||||
$Strings->get("First", false),
|
||||
$Strings->get("Last", false),
|
||||
$Strings->get("Phone", false),
|
||||
$Strings->get("Email", false),
|
||||
$Strings->get("Address", false),
|
||||
$Strings->get("ZIP", false),
|
||||
$Strings->get("Days", false),
|
||||
$Strings->get("Position", false),
|
||||
$Strings->get("Shirt", false),
|
||||
$Strings->get("Sex", false)
|
||||
];
|
||||
break;
|
||||
case 3:
|
||||
$newsletter = $Strings->get("Email+Print", false);
|
||||
case "Youth":
|
||||
$join = ["[>]youth" => ["youthid" => "youthid"]];
|
||||
$where = ["people.youthid[!]" => null];
|
||||
$header = [
|
||||
$Strings->get("First", false),
|
||||
$Strings->get("Last", false),
|
||||
$Strings->get("Parent", false),
|
||||
$Strings->get("Phone", false),
|
||||
$Strings->get("Parent Phone", false),
|
||||
$Strings->get("Email", false),
|
||||
$Strings->get("Address", false),
|
||||
$Strings->get("ZIP", false),
|
||||
$Strings->get("Days", false),
|
||||
$Strings->get("Position", false),
|
||||
$Strings->get("Shirt", false),
|
||||
$Strings->get("Sex", false)
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$header = [
|
||||
$Strings->get("First", false),
|
||||
$Strings->get("Last", false),
|
||||
$Strings->get("Type", false),
|
||||
$Strings->get("Phone", false),
|
||||
$Strings->get("Email", false),
|
||||
$Strings->get("Address", false),
|
||||
$Strings->get("ZIP", false),
|
||||
$Strings->get("Shirt", false),
|
||||
$Strings->get("Sex", false)
|
||||
];
|
||||
}
|
||||
$children = [];
|
||||
foreach ($f->getChildren() as $c) {
|
||||
$children[] = $c->getName() . " (" . date("n/d", $c->getBirthday()) . ")";
|
||||
|
||||
if (empty($join)) {
|
||||
$people = $database->select("people", '*', $where);
|
||||
} else {
|
||||
$people = $database->select("people", $join, '*', $where);
|
||||
}
|
||||
$report->addDataRow([
|
||||
$f->getName(),
|
||||
$f->getFather(),
|
||||
$f->getMother(),
|
||||
$f->getPhone() . "",
|
||||
$f->getEmail(),
|
||||
$f->getAddress(),
|
||||
$f->getCity(),
|
||||
$f->getState(),
|
||||
$f->getZip() . "",
|
||||
$f->getPhotoPermission() ? $Strings->get("Yes", false) : $Strings->get("No", false),
|
||||
$newsletter,
|
||||
date("Y-m-d", $f->getExpires()),
|
||||
$f->getPrivate() ? $Strings->get("Yes", false) : $Strings->get("No", false),
|
||||
implode(", ", $children)
|
||||
]);
|
||||
|
||||
$report->setHeader($header);
|
||||
|
||||
foreach ($people as $p) {
|
||||
$row = [];
|
||||
|
||||
$type = "Unknown";
|
||||
if (!empty($p['camperid'])) {
|
||||
$type = $Strings->get("Camper", false);
|
||||
} else if (!empty($p['adultid'])) {
|
||||
$type = $Strings->get("Adult", false);
|
||||
} else if (!empty($p['youthid'])) {
|
||||
$type = $Strings->get("Youth", false);
|
||||
}
|
||||
|
||||
switch ($filter) {
|
||||
case "Campers":
|
||||
$row = [
|
||||
$p['firstname'],
|
||||
$p['lastname'],
|
||||
$p['parentname'],
|
||||
$p['unit'],
|
||||
$p['rank'],
|
||||
$p['phone1'],
|
||||
$p['email'],
|
||||
$p['address'],
|
||||
$p['zip'],
|
||||
$p['shirt'],
|
||||
$p['sex']
|
||||
];
|
||||
break;
|
||||
case "Adults":
|
||||
$row = [
|
||||
$p['firstname'],
|
||||
$p['lastname'],
|
||||
$p['phone1'],
|
||||
$p['email'],
|
||||
$p['address'],
|
||||
$p['zip'],
|
||||
$p['days'],
|
||||
$p['position'],
|
||||
$p['shirt'],
|
||||
$p['sex']
|
||||
];
|
||||
break;
|
||||
case "Youth":
|
||||
$row = [
|
||||
$p['firstname'],
|
||||
$p['lastname'],
|
||||
$p['parentname'],
|
||||
$p['phone1'],
|
||||
$p['phone2'],
|
||||
$p['email'],
|
||||
$p['address'],
|
||||
$p['zip'],
|
||||
$p['days'],
|
||||
$p['position'],
|
||||
$p['shirt'],
|
||||
$p['sex']
|
||||
];
|
||||
break;
|
||||
default:
|
||||
$row = [
|
||||
$p['firstname'],
|
||||
$p['lastname'],
|
||||
$type,
|
||||
$p['phone1'] . (empty($p['phone2']) ? "" : " " . $p['phone2']),
|
||||
$p['email'],
|
||||
$p['address'],
|
||||
$p['zip'],
|
||||
$p['shirt'],
|
||||
$p['sex']
|
||||
];
|
||||
}
|
||||
|
||||
$report->addDataRow($row);
|
||||
}
|
||||
return $report;
|
||||
}
|
||||
|
||||
function getReport($type): Report {
|
||||
switch ($type) {
|
||||
case "members":
|
||||
return getMemberReport();
|
||||
case "campers":
|
||||
return getPeopleReport("Campers");
|
||||
break;
|
||||
case "expiring":
|
||||
return getMemberReport(["expires[<]" => date("Y-m-d", strtotime("+1 month")), "ORDER" => ["expires" => "ASC"]]);
|
||||
case "adults":
|
||||
return getPeopleReport("Adults");
|
||||
break;
|
||||
case "youth":
|
||||
return getPeopleReport("Youth");
|
||||
break;
|
||||
case "people":
|
||||
return getPeopleReport("");
|
||||
break;
|
||||
default:
|
||||
return new Report("error", ["ERROR"], ["Invalid report type."]);
|
||||
|
@ -20,47 +20,58 @@ if (!$user->hasPermission("HACHEPORTAL_VIEW")) {
|
||||
</h3>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-12 col-md-4">
|
||||
<h4><?php $Strings->get("Member Directory"); ?></h4>
|
||||
<p><?php $Strings->get("A formatted and up-to-date HACHE member directory."); ?></p>
|
||||
<a class="btn btn-primary mb-1" href="./lib/mkmemberdirectory.php?format=odt">
|
||||
<i class="far fa-file-alt"></i> <?php $Strings->get("Office (ODT)"); ?>
|
||||
</a>
|
||||
<br />
|
||||
<a class="btn btn-orange btn-sm mr-1" href="./lib/mkmemberdirectory.php?format=html">
|
||||
<i class="fas fa-globe"></i> <?php $Strings->get("HTML"); ?>
|
||||
</a>
|
||||
<a class="btn btn-secondary btn-sm" href="./lib/mkmemberdirectory.php?format=docx">
|
||||
<i class="fas fa-file-word"></i> <?php $Strings->get("DOCX"); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-4">
|
||||
<h4><?php $Strings->get("Family List"); ?></h4>
|
||||
<p><?php $Strings->get("All the data from the member directory in a spreadsheet."); ?></p>
|
||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=members&format=ods">
|
||||
<div class="col-12 col-md-3">
|
||||
<h4><?php $Strings->get("Campers"); ?></h4>
|
||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=campers&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=members&format=html">
|
||||
<i class="fas fa-globe"></i> <?php $Strings->get("HTML"); ?>
|
||||
<a class="btn btn-orange btn-sm mr-1" href="./lib/reports.php?type=campers&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=members&format=csv">
|
||||
<a class="btn btn-secondary btn-sm" href="./lib/reports.php?type=campers&format=csv">
|
||||
<i class="fas fa-file-csv"></i> <?php $Strings->get("CSV"); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-4">
|
||||
<h4><?php $Strings->get("Expiring Memberships"); ?></h4>
|
||||
<p><?php $Strings->get("All members expired or expiring within a month."); ?></p>
|
||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=expiring&format=ods">
|
||||
<div class="col-12 col-md-3">
|
||||
<h4><?php $Strings->get("Adults"); ?></h4>
|
||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=adults&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=expiring&format=html">
|
||||
<i class="fas fa-globe"></i> <?php $Strings->get("HTML"); ?>
|
||||
<a class="btn btn-orange btn-sm mr-1" href="./lib/reports.php?type=adults&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=expiring&format=csv">
|
||||
<a class="btn btn-secondary btn-sm" href="./lib/reports.php?type=adults&format=csv">
|
||||
<i class="fas fa-file-csv"></i> <?php $Strings->get("CSV"); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3">
|
||||
<h4><?php $Strings->get("Youth"); ?></h4>
|
||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=youth&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=youth&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=youth&format=csv">
|
||||
<i class="fas fa-file-csv"></i> <?php $Strings->get("CSV"); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
<div class="col-12 col-md-3">
|
||||
<h4><?php $Strings->get("People"); ?></h4>
|
||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=people&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=people&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=people&format=csv">
|
||||
<i class="fas fa-file-csv"></i> <?php $Strings->get("CSV"); ?>
|
||||
</a>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user