Add child_care field for adults with young children
This commit is contained in:
parent
16425c5cbb
commit
56526cb8ce
13
action.php
13
action.php
@ -58,6 +58,7 @@ switch ($VARS['action']) {
|
|||||||
"den" => "",
|
"den" => "",
|
||||||
"health" => "",
|
"health" => "",
|
||||||
"notes" => "",
|
"notes" => "",
|
||||||
|
"child_care" => null,
|
||||||
"position" => ""
|
"position" => ""
|
||||||
];
|
];
|
||||||
if (!empty($VARS['personid']) && $database->has("people", ['personid' => $VARS['personid']])) {
|
if (!empty($VARS['personid']) && $database->has("people", ['personid' => $VARS['personid']])) {
|
||||||
@ -204,9 +205,18 @@ switch ($VARS['action']) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "adult":
|
case "adult":
|
||||||
|
if (!empty($people["child_care"])) {
|
||||||
|
$items = preg_split("/[^\d]+/", $people["child_care"]);
|
||||||
|
$ages = [];
|
||||||
|
foreach ($items as $it) {
|
||||||
|
$ages[] = $it;
|
||||||
|
}
|
||||||
|
$people["child_care"] = implode(",", $ages);
|
||||||
|
}
|
||||||
$data = [
|
$data = [
|
||||||
"position" => $people["position"],
|
"position" => $people["position"],
|
||||||
"days" => $days
|
"days" => $days,
|
||||||
|
"child_care" => empty($people["child_care"]) ? null : $people["child_care"]
|
||||||
];
|
];
|
||||||
if ($editing) {
|
if ($editing) {
|
||||||
$database->update("adults", $data, ['adultid' => $person['adultid']]);
|
$database->update("adults", $data, ['adultid' => $person['adultid']]);
|
||||||
@ -255,7 +265,6 @@ switch ($VARS['action']) {
|
|||||||
} else {
|
} else {
|
||||||
$database->insert("people", $data);
|
$database->insert("people", $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception $ex) {
|
} catch (Exception $ex) {
|
||||||
errorBack($ex->getMessage());
|
errorBack($ex->getMessage());
|
||||||
}
|
}
|
||||||
|
BIN
database.mwb
BIN
database.mwb
Binary file not shown.
@ -33,6 +33,9 @@
|
|||||||
"Den": "Den",
|
"Den": "Den",
|
||||||
"Health": "Health",
|
"Health": "Health",
|
||||||
"Notes": "Notes",
|
"Notes": "Notes",
|
||||||
|
"Child Care Ages": "Child Care Ages",
|
||||||
|
"Age": "Age",
|
||||||
|
"Count": "Count",
|
||||||
"Total": "Total",
|
"Total": "Total",
|
||||||
"Yes": "Yes",
|
"Yes": "Yes",
|
||||||
"No": "No",
|
"No": "No",
|
||||||
|
@ -29,7 +29,7 @@ if (LOADED) {
|
|||||||
/**
|
/**
|
||||||
* Get a 2d array of the families in the database.
|
* Get a 2d array of the families in the database.
|
||||||
* @global type $database
|
* @global type $database
|
||||||
* @param array $filter Medoo WHERE clause.
|
* @param string $filter
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function getPeopleReport($filter = ""): Report {
|
function getPeopleReport($filter = ""): Report {
|
||||||
@ -80,6 +80,7 @@ function getPeopleReport($filter = ""): Report {
|
|||||||
$Strings->get("Position", false),
|
$Strings->get("Position", false),
|
||||||
$Strings->get("Shirt", false),
|
$Strings->get("Shirt", false),
|
||||||
$Strings->get("Sex", false),
|
$Strings->get("Sex", false),
|
||||||
|
$Strings->get("Child Care Ages", false),
|
||||||
$Strings->get("Notes", false)
|
$Strings->get("Notes", false)
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
@ -168,6 +169,7 @@ function getPeopleReport($filter = ""): Report {
|
|||||||
$p['position'],
|
$p['position'],
|
||||||
$p['shirt'],
|
$p['shirt'],
|
||||||
$p['sex'],
|
$p['sex'],
|
||||||
|
$p['child_care'],
|
||||||
$p['notes']
|
$p['notes']
|
||||||
];
|
];
|
||||||
break;
|
break;
|
||||||
@ -208,6 +210,62 @@ function getPeopleReport($filter = ""): Report {
|
|||||||
return $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 {
|
function getReport($type): Report {
|
||||||
switch ($type) {
|
switch ($type) {
|
||||||
case "campers":
|
case "campers":
|
||||||
@ -222,6 +280,9 @@ function getReport($type): Report {
|
|||||||
case "people":
|
case "people":
|
||||||
return getPeopleReport("");
|
return getPeopleReport("");
|
||||||
break;
|
break;
|
||||||
|
case "childcare":
|
||||||
|
return getChildCareReport();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
return new Report("error", ["ERROR"], ["Invalid report type."]);
|
return new Report("error", ["ERROR"], ["Invalid report type."]);
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,8 @@ $data = [
|
|||||||
"days" => "",
|
"days" => "",
|
||||||
"den" => "",
|
"den" => "",
|
||||||
"health" => "",
|
"health" => "",
|
||||||
"notes" => ""
|
"notes" => "",
|
||||||
|
"child_care" => ""
|
||||||
];
|
];
|
||||||
$type = "camper";
|
$type = "camper";
|
||||||
if (!empty($VARS['type']) && preg_match("/(camper|adult|youth)/", $VARS['type'])) {
|
if (!empty($VARS['type']) && preg_match("/(camper|adult|youth)/", $VARS['type'])) {
|
||||||
@ -58,7 +59,7 @@ if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']])
|
|||||||
$data = array_merge($data, $database->get('campers', ['parentname', 'rank', 'den', 'health'], ['camperid' => $data["camperid"]]));
|
$data = array_merge($data, $database->get('campers', ['parentname', 'rank', 'den', 'health'], ['camperid' => $data["camperid"]]));
|
||||||
} else if (!empty($data["adultid"])) {
|
} else if (!empty($data["adultid"])) {
|
||||||
$type = "adult";
|
$type = "adult";
|
||||||
$data = array_merge($data, $database->get('adults', ['days', 'position'], ['adultid' => $data["adultid"]]));
|
$data = array_merge($data, $database->get('adults', ['days', 'position', 'child_care'], ['adultid' => $data["adultid"]]));
|
||||||
} else if (!empty($data["youthid"])) {
|
} else if (!empty($data["youthid"])) {
|
||||||
$type = "youth";
|
$type = "youth";
|
||||||
$data = array_merge($data, $database->get('youth', ['days', 'position', 'parentname'], ['youthid' => $data["youthid"]]));
|
$data = array_merge($data, $database->get('youth', ['days', 'position', 'parentname'], ['youthid' => $data["youthid"]]));
|
||||||
@ -382,6 +383,17 @@ if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']])
|
|||||||
]
|
]
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
if ($type == "adult") {
|
||||||
|
$textboxes = array_merge($textboxes, [
|
||||||
|
[
|
||||||
|
"label" => "Child care ages",
|
||||||
|
"name" => "child_care",
|
||||||
|
"optional" => true,
|
||||||
|
"width" => 6,
|
||||||
|
"value" => $data["child_care"]
|
||||||
|
],
|
||||||
|
]);
|
||||||
|
}
|
||||||
$textboxes = array_merge($textboxes, [
|
$textboxes = array_merge($textboxes, [
|
||||||
[
|
[
|
||||||
"label" => "Notes",
|
"label" => "Notes",
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
</h3>
|
</h3>
|
||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12 col-md-3">
|
<div class="col-12 col-md-3 mb-4">
|
||||||
<h4><?php $Strings->get("Campers"); ?></h4>
|
<h4><?php $Strings->get("Campers"); ?></h4>
|
||||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=campers&format=ods">
|
<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)"); ?>
|
<i class="fas fa-table"></i> <?php $Strings->get("Spreadsheet (ODS)"); ?>
|
||||||
@ -29,7 +29,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 col-md-3">
|
<div class="col-12 col-md-3 mb-4">
|
||||||
<h4><?php $Strings->get("Adults"); ?></h4>
|
<h4><?php $Strings->get("Adults"); ?></h4>
|
||||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=adults&format=ods">
|
<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)"); ?>
|
<i class="fas fa-table"></i> <?php $Strings->get("Spreadsheet (ODS)"); ?>
|
||||||
@ -43,7 +43,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 col-md-3">
|
<div class="col-12 col-md-3 mb-4">
|
||||||
<h4><?php $Strings->get("Youth"); ?></h4>
|
<h4><?php $Strings->get("Youth"); ?></h4>
|
||||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=youth&format=ods">
|
<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)"); ?>
|
<i class="fas fa-table"></i> <?php $Strings->get("Spreadsheet (ODS)"); ?>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-12 col-md-3">
|
<div class="col-12 col-md-3 mb-4">
|
||||||
<h4><?php $Strings->get("People"); ?></h4>
|
<h4><?php $Strings->get("People"); ?></h4>
|
||||||
<a class="btn btn-success mb-1" href="./lib/reports.php?type=people&format=ods">
|
<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)"); ?>
|
<i class="fas fa-table"></i> <?php $Strings->get("Spreadsheet (ODS)"); ?>
|
||||||
@ -70,6 +70,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("Child Care Ages"); ?></h4>
|
||||||
|
<a class="btn btn-success mb-1" href="./lib/reports.php?type=childcare&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=childcare&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=childcare&format=csv">
|
||||||
|
<i class="fas fa-file-csv"></i> <?php $Strings->get("CSV"); ?>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
@ -160,6 +160,14 @@ $database->action(function($database) {
|
|||||||
$dueusd += 10.0;
|
$dueusd += 10.0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (!empty($people["child_care"][$pid])) {
|
||||||
|
$items = preg_split("/[^\d]+/", $people["child_care"][$pid]);
|
||||||
|
$ages = [];
|
||||||
|
foreach ($items as $it) {
|
||||||
|
$ages[] = $it;
|
||||||
|
}
|
||||||
|
$people["child_care"][$pid] = implode(",", $ages);
|
||||||
|
}
|
||||||
$database->insert("adults", [
|
$database->insert("adults", [
|
||||||
"position" => $people["position"][$pid],
|
"position" => $people["position"][$pid],
|
||||||
"days" => $days,
|
"days" => $days,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user