hasPermission("HACHEPORTAL_EDIT")) { header("Location: ./app.php?msg=no_permission"); die(); } $editing = false; $data = [ "id" => "", "family" => "", "amount" => 1.0, "date" => date("Y-m-d"), "type" => "", "paid" => true ]; if (!empty($_GET['id']) && $database->has('payments', ['paymentid' => $_GET['id']])) { $editing = true; $payment = $database->get("payments", ['paymentid (id)', "familyid (family)", "amount", "date", "type", "paid"], ["paymentid" => $_GET['id']]); $payment["date"] = date("Y-m-d", strtotime($payment["date"])); $payment["paid"] = ($payment["paid"] == 1 ? true : false); $data = $payment; } ?>

get("Edit Payment"); } else { $Strings->get("Add Payment"); } ?>
get("Cancel"); ?>

select("families", ["familyid (id)", "familyname (name)", "mother_name", "father_name"]); $familylist = [ "" => $Strings->get("Choose...", false) ]; foreach ($families as $f) { if (!empty($f["father_name"]) && !empty($f["mother_name"])) { $familylist[$f['id']] = "$f[name], $f[father_name] and $f[mother_name]"; } else if (!empty($f["father_name"])) { $familylist[$f['id']] = "$f[name], $f[father_name]"; } else if (!empty($f["mother_name"])) { $familylist[$f['id']] = "$f[name], $f[mother_name]"; } } $textboxes = [ [ "label" => "Family", "icon" => "fas fa-users", "name" => "familyid", "type" => "select", "value" => $data["family"], "options" => $familylist, "error" => "Choose a family." ], [ "label" => "Amount", "icon" => "fas fa-dollar-sign", "name" => "amount", "type" => "number", "maxlength" => 5, "value" => $data["amount"], "width" => 2, "error" => "Enter a dollar amount." ], [ "label" => "Date", "icon" => "fas fa-calendar", "name" => "date", "type" => "date", "value" => $data["date"], "width" => 3, "error" => "Choose a date for the payment." ], [ "label" => "Type", "icon" => "fas fa-money-bill", "name" => "type", "type" => "select", "value" => $data["type"], "options" => [ "" => $Strings->get("Choose...", false), "Online" => "Online", "Cash" => "Cash", "Check" => "Check", "Free" => "Free", "Other" => "Other" ], "width" => 3, "error" => "Select a payment type." ] ]; foreach ($textboxes as $item) { ?>
">
" name="" class="form-control" placeholder="" aria-label="" maxlength="" pattern="" value="" required />
>
" />