Add family ID search tool, fixes
This commit is contained in:
parent
17009bd496
commit
628366379b
46
action.php
46
action.php
@ -83,8 +83,9 @@ switch ($VARS['action']) {
|
|||||||
global $person, $VARS, $editing;
|
global $person, $VARS, $editing;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
if (!empty($VARS['familyid']) && $database->has('families', ['familyid' => $VARS['familyid']])) {
|
||||||
if ($editing) {
|
$familyid = $VARS['familyid'];
|
||||||
|
} else if ($editing) {
|
||||||
$familyid = $person['familyid'];
|
$familyid = $person['familyid'];
|
||||||
} else {
|
} else {
|
||||||
$database->insert("families", []);
|
$database->insert("families", []);
|
||||||
@ -132,7 +133,8 @@ switch ($VARS['action']) {
|
|||||||
"Station",
|
"Station",
|
||||||
"Tot Lot",
|
"Tot Lot",
|
||||||
"Floater"
|
"Floater"
|
||||||
]
|
],
|
||||||
|
"parentname" => ".+"
|
||||||
]);
|
]);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
@ -208,7 +210,8 @@ switch ($VARS['action']) {
|
|||||||
case "youth":
|
case "youth":
|
||||||
$data = [
|
$data = [
|
||||||
"position" => $people["position"],
|
"position" => $people["position"],
|
||||||
"days" => $days
|
"days" => $days,
|
||||||
|
"parentname" => $people["parentname"]
|
||||||
];
|
];
|
||||||
if ($editing) {
|
if ($editing) {
|
||||||
$database->update("youth", $data, ['youthid' => $person['youthid']]);
|
$database->update("youth", $data, ['youthid' => $person['youthid']]);
|
||||||
@ -219,7 +222,6 @@ switch ($VARS['action']) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
"familyid" => $familyid,
|
"familyid" => $familyid,
|
||||||
"camperid" => $camperid,
|
"camperid" => $camperid,
|
||||||
@ -242,6 +244,7 @@ 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());
|
||||||
}
|
}
|
||||||
@ -266,15 +269,15 @@ switch ($VARS['action']) {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "editpayment":
|
case "editpayment":
|
||||||
if (!(new User($_SESSION['uid']))->hasPermission("HACHEPORTAL_EDIT")) {
|
|
||||||
returnToSender("no_permission");
|
|
||||||
}
|
|
||||||
if (!$database->has("families", ['familyid' => $VARS['familyid']])) {
|
if (!$database->has("families", ['familyid' => $VARS['familyid']])) {
|
||||||
returnToSender("invalid_parameters");
|
returnToSender("invalid_parameters");
|
||||||
}
|
}
|
||||||
if (!is_numeric($VARS["amount"]) || $VARS["amount"] < 0) {
|
if (!is_numeric($VARS["amount"]) || $VARS["amount"] < 0) {
|
||||||
returnToSender("invalid_parameters");
|
returnToSender("invalid_parameters");
|
||||||
}
|
}
|
||||||
|
if (!is_numeric($VARS["amountpaid"]) || $VARS["amountpaid"] < 0) {
|
||||||
|
returnToSender("invalid_parameters");
|
||||||
|
}
|
||||||
if (empty($VARS['date']) || strtotime($VARS['date']) === false) {
|
if (empty($VARS['date']) || strtotime($VARS['date']) === false) {
|
||||||
returnToSender("invalid_parameters");
|
returnToSender("invalid_parameters");
|
||||||
}
|
}
|
||||||
@ -282,7 +285,7 @@ switch ($VARS['action']) {
|
|||||||
$database->update("payments", [
|
$database->update("payments", [
|
||||||
"familyid" => $VARS["familyid"],
|
"familyid" => $VARS["familyid"],
|
||||||
"amount" => $VARS["amount"],
|
"amount" => $VARS["amount"],
|
||||||
"paid" => !empty($VARS["paid"]) && $VARS["paid"] == "1" ? true : false,
|
"amountpaid" => $VARS["amountpaid"],
|
||||||
"date" => date("Y-m-d H:i:s", strtotime($VARS['date'])),
|
"date" => date("Y-m-d H:i:s", strtotime($VARS['date'])),
|
||||||
"type" => $VARS["type"]
|
"type" => $VARS["type"]
|
||||||
], [
|
], [
|
||||||
@ -293,19 +296,28 @@ switch ($VARS['action']) {
|
|||||||
$database->insert("payments", [
|
$database->insert("payments", [
|
||||||
"familyid" => $VARS["familyid"],
|
"familyid" => $VARS["familyid"],
|
||||||
"amount" => $VARS["amount"],
|
"amount" => $VARS["amount"],
|
||||||
"paid" => !empty($VARS["paid"]) && $VARS["paid"] == "1" ? true : false,
|
"amountpaid" => $VARS["amountpaid"],
|
||||||
"date" => date("Y-m-d H:i:s", strtotime($VARS['date'])),
|
"date" => date("Y-m-d H:i:s", strtotime($VARS['date'])),
|
||||||
"type" => $VARS["type"]
|
"type" => $VARS["type"]
|
||||||
]);
|
]);
|
||||||
$paymentid = $database->id();
|
$paymentid = $database->id();
|
||||||
$family = (new Family())->load($VARS['familyid']);
|
|
||||||
if ($family->getExpires() < time()) {
|
|
||||||
$family->setExpires(strtotime("+1 year"));
|
|
||||||
} else {
|
|
||||||
$family->setExpires(strtotime("+1 year", $family->getExpires()));
|
|
||||||
}
|
|
||||||
$family->save();
|
|
||||||
}
|
}
|
||||||
returnToSender("payment_saved", "&id=$paymentid");
|
returnToSender("payment_saved", "&id=$paymentid");
|
||||||
break;
|
break;
|
||||||
|
case "familysearch":
|
||||||
|
$people = $database->select('people', ['familyid (id)', 'firstname', 'lastname'], ['OR' => ['familyid' => $VARS['q'], 'lastname[~]' => $VARS['q'], 'firstname[~]' => $VARS['q']]]);
|
||||||
|
$data = [];
|
||||||
|
foreach ($people as $p) {
|
||||||
|
$data[$p['id']]['names'][] = $p['firstname'] . " " . $p['lastname'];
|
||||||
|
$data[$p['id']]['id'] = $p['id'];
|
||||||
|
}
|
||||||
|
$out = [];
|
||||||
|
foreach ($data as $i) {
|
||||||
|
$out[] = [
|
||||||
|
'id' => $i['id'],
|
||||||
|
'name' => implode(", ", $i['names'])
|
||||||
|
];
|
||||||
|
}
|
||||||
|
header('Content-Type: application/json');
|
||||||
|
echo json_encode($out);
|
||||||
}
|
}
|
BIN
database.mwb
BIN
database.mwb
Binary file not shown.
@ -21,20 +21,16 @@ define("MESSAGES", [
|
|||||||
"string" => "You do not have permission to do that.",
|
"string" => "You do not have permission to do that.",
|
||||||
"type" => "danger"
|
"type" => "danger"
|
||||||
],
|
],
|
||||||
"family_doesnt_exist" => [
|
"person_doesnt_exist" => [
|
||||||
"string" => "That family ID does not exist.",
|
"string" => "That person does not exist.",
|
||||||
"type" => "warning"
|
"type" => "warning"
|
||||||
],
|
],
|
||||||
"family_saved" => [
|
"person_saved" => [
|
||||||
"string" => "Family saved.",
|
"string" => "Person saved.",
|
||||||
"type" => "success"
|
"type" => "success"
|
||||||
],
|
],
|
||||||
"family_deleted" => [
|
"person_deleted" => [
|
||||||
"string" => "Family deleted.",
|
"string" => "Person deleted.",
|
||||||
"type" => "success"
|
|
||||||
],
|
|
||||||
"events_updated" => [
|
|
||||||
"string" => "Events updated.",
|
|
||||||
"type" => "success"
|
"type" => "success"
|
||||||
],
|
],
|
||||||
"payment_saved" => [
|
"payment_saved" => [
|
||||||
|
@ -27,7 +27,8 @@ define("PAGES", [
|
|||||||
"editperson" => [
|
"editperson" => [
|
||||||
"title" => "Edit Person",
|
"title" => "Edit Person",
|
||||||
"scripts" => [
|
"scripts" => [
|
||||||
"static/js/editperson.js"
|
"static/js/editperson.js",
|
||||||
|
"static/js/familysearch.js"
|
||||||
],
|
],
|
||||||
],
|
],
|
||||||
"confirmdelete" => [
|
"confirmdelete" => [
|
||||||
@ -49,7 +50,8 @@ define("PAGES", [
|
|||||||
"editpayment" => [
|
"editpayment" => [
|
||||||
"title" => "Edit Payment",
|
"title" => "Edit Payment",
|
||||||
"scripts" => [
|
"scripts" => [
|
||||||
"static/js/editpayment.js"
|
"static/js/editpayment.js",
|
||||||
|
"static/js/familysearch.js"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
"reports" => [
|
"reports" => [
|
||||||
|
@ -16,10 +16,10 @@ $editing = false;
|
|||||||
$data = [
|
$data = [
|
||||||
"id" => "",
|
"id" => "",
|
||||||
"family" => "",
|
"family" => "",
|
||||||
"amount" => 1.0,
|
"amount" => 0.0,
|
||||||
|
"amountpaid" => 0.0,
|
||||||
"date" => date("Y-m-d"),
|
"date" => date("Y-m-d"),
|
||||||
"type" => "",
|
"type" => ""
|
||||||
"paid" => true
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if (!empty($_GET['id']) && $database->has('payments', ['paymentid' => $_GET['id']])) {
|
if (!empty($_GET['id']) && $database->has('payments', ['paymentid' => $_GET['id']])) {
|
||||||
@ -30,6 +30,24 @@ if (!empty($_GET['id']) && $database->has('payments', ['paymentid' => $_GET['id'
|
|||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<div class="modal fade" id="familysearchmodal">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Find Family</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="text" id="familysearchbox" class="form-control" placeholder="Type to Search" />
|
||||||
|
<div class="list-group" id="familysearchresults">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form action="action.php" method="post" id="editform">
|
<form action="action.php" method="post" id="editform">
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@ -52,6 +70,29 @@ if (!empty($_GET['id']) && $database->has('payments', ['paymentid' => $_GET['id'
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-12 col-md-2">
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label class="mb-0">Family ID:</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="btn btn-default" id="familysearchbtn"><i class="fas fa-search"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="number"
|
||||||
|
name="familyid"
|
||||||
|
value="<?php echo $data['family']; ?>"
|
||||||
|
class="form-control"
|
||||||
|
placeholder=""
|
||||||
|
aria-label="Family ID"
|
||||||
|
maxlength="5"
|
||||||
|
required />
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
Enter a family ID.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$textboxes = [
|
$textboxes = [
|
||||||
[
|
[
|
||||||
@ -94,7 +135,9 @@ if (!empty($_GET['id']) && $database->has('payments', ['paymentid' => $_GET['id'
|
|||||||
"Online" => "Online",
|
"Online" => "Online",
|
||||||
"Cash" => "Cash",
|
"Cash" => "Cash",
|
||||||
"Check" => "Check",
|
"Check" => "Check",
|
||||||
|
"Camp Coupon/Scout Bucks" => "Camp Coupon/Scout Bucks",
|
||||||
"Free" => "Free",
|
"Free" => "Free",
|
||||||
|
"Multiple" => "Multiple",
|
||||||
"Other" => "Other"
|
"Other" => "Other"
|
||||||
],
|
],
|
||||||
"width" => 3,
|
"width" => 3,
|
||||||
|
@ -10,6 +10,7 @@ redirectIfNotLoggedIn();
|
|||||||
$editing = false;
|
$editing = false;
|
||||||
$data = [
|
$data = [
|
||||||
"id" => null,
|
"id" => null,
|
||||||
|
"familyid" => "",
|
||||||
"camperid" => null,
|
"camperid" => null,
|
||||||
"adultid" => null,
|
"adultid" => null,
|
||||||
"youthid" => null,
|
"youthid" => null,
|
||||||
@ -34,6 +35,7 @@ if (!empty($VARS['type']) && preg_match("/(camper|adult|youth)/", $VARS['type'])
|
|||||||
if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']])) {
|
if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']])) {
|
||||||
$personid = $VARS['id'];
|
$personid = $VARS['id'];
|
||||||
$data = $database->get('people', ['personid (id)',
|
$data = $database->get('people', ['personid (id)',
|
||||||
|
'familyid',
|
||||||
'camperid',
|
'camperid',
|
||||||
'adultid',
|
'adultid',
|
||||||
'youthid',
|
'youthid',
|
||||||
@ -55,12 +57,30 @@ if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']])
|
|||||||
$data = array_merge($data, $database->get('adults', ['days', 'position'], ['adultid' => $data["adultid"]]));
|
$data = array_merge($data, $database->get('adults', ['days', 'position'], ['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'], ['youthid' => $data["youthid"]]));
|
$data = array_merge($data, $database->get('youth', ['days', 'position', 'parentname'], ['youthid' => $data["youthid"]]));
|
||||||
}
|
}
|
||||||
$editing = true;
|
$editing = true;
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
||||||
|
<div class="modal fade" id="familysearchmodal">
|
||||||
|
<div class="modal-dialog" role="document">
|
||||||
|
<div class="modal-content">
|
||||||
|
<div class="modal-header">
|
||||||
|
<h5 class="modal-title">Find Family</h5>
|
||||||
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
|
||||||
|
<span aria-hidden="true">×</span>
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
<div class="modal-body">
|
||||||
|
<input type="text" id="familysearchbox" class="form-control" placeholder="Type to Search" />
|
||||||
|
<div class="list-group" id="familysearchresults">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<form action="action.php" method="post" id="editform">
|
<form action="action.php" method="post" id="editform">
|
||||||
|
|
||||||
<div class="card">
|
<div class="card">
|
||||||
@ -88,20 +108,41 @@ if (!empty($VARS['id']) && $database->has('people', ['personid' => $VARS['id']])
|
|||||||
|
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
||||||
|
<div class="col-12 col-md-2">
|
||||||
|
<div class="form-group mb-3">
|
||||||
|
<label class="mb-0">Family ID:</label>
|
||||||
|
<div class="input-group">
|
||||||
|
<div class="input-group-prepend">
|
||||||
|
<span class="btn btn-default" id="familysearchbtn"><i class="fas fa-search"></i></span>
|
||||||
|
</div>
|
||||||
|
<input type="number"
|
||||||
|
name="familyid"
|
||||||
|
value="<?php echo $data['familyid']; ?>"
|
||||||
|
class="form-control"
|
||||||
|
placeholder=""
|
||||||
|
aria-label="Family ID"
|
||||||
|
maxlength="5" />
|
||||||
|
<div class="invalid-feedback">
|
||||||
|
Enter a family ID.
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<?php
|
<?php
|
||||||
$textboxes = [
|
$textboxes = [
|
||||||
[
|
[
|
||||||
"label" => "First Name",
|
"label" => "First Name",
|
||||||
"name" => "firstname",
|
"name" => "firstname",
|
||||||
"maxlength" => 255,
|
"maxlength" => 255,
|
||||||
"width" => 6,
|
"width" => 5,
|
||||||
"value" => $data["firstname"],
|
"value" => $data["firstname"],
|
||||||
"error" => "Enter the person's first name."
|
"error" => "Enter the person's first name."
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
"label" => "Last Name",
|
"label" => "Last Name",
|
||||||
"name" => "lastname",
|
"name" => "lastname",
|
||||||
"width" => 6,
|
"width" => 5,
|
||||||
"maxlength" => 255,
|
"maxlength" => 255,
|
||||||
"value" => $data["lastname"],
|
"value" => $data["lastname"],
|
||||||
"error" => "Enter the person's last name."
|
"error" => "Enter the person's last name."
|
||||||
|
@ -1,34 +0,0 @@
|
|||||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
||||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
||||||
|
|
||||||
$('#famtable').DataTable({
|
|
||||||
responsive: {
|
|
||||||
details: {
|
|
||||||
display: $.fn.dataTable.Responsive.display.modal({
|
|
||||||
header: function (row) {
|
|
||||||
var data = row.data();
|
|
||||||
return "<i class=\"fas fa-users fa-fw\"></i> " + data[2];
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
renderer: $.fn.dataTable.Responsive.renderer.tableAll({
|
|
||||||
tableClass: 'table'
|
|
||||||
}),
|
|
||||||
type: "column"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
columnDefs: [
|
|
||||||
{
|
|
||||||
targets: 0,
|
|
||||||
className: 'control',
|
|
||||||
orderable: false
|
|
||||||
},
|
|
||||||
{
|
|
||||||
targets: 1,
|
|
||||||
orderable: false
|
|
||||||
}
|
|
||||||
],
|
|
||||||
order: [
|
|
||||||
[2, 'asc']
|
|
||||||
]
|
|
||||||
});
|
|
24
static/js/familysearch.js
Normal file
24
static/js/familysearch.js
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||||
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||||
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
|
$("#familysearchbtn").click(function () {
|
||||||
|
$("#familysearchmodal").modal("show");
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#familysearchmodal #familysearchbox").on("input propertychange paste", function () {
|
||||||
|
$.getJSON("action.php", {
|
||||||
|
action: "familysearch",
|
||||||
|
q: $("#familysearchbox").val()
|
||||||
|
}, function (resp) {
|
||||||
|
$("#familysearchresults").html("");
|
||||||
|
for (var i = 0; i < resp.length; i++) {
|
||||||
|
$("#familysearchresults").append('<div class="list-group-item familysearchresult" data-familyid="' + resp[i]['id'] + '">' + resp[i]['name'] + '</div>');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#familysearchmodal").on("click", ".familysearchresult", function () {
|
||||||
|
$("input[name=familyid]").val($(this).data("familyid"));
|
||||||
|
$("#familysearchmodal").modal("hide");
|
||||||
|
});
|
Loading…
x
Reference in New Issue
Block a user