You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

63 lines
2.0 KiB
PHP

<?php
/*
* 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/.
*/
redirectIfNotLoggedIn();
$user = new User($_SESSION['uid']);
if (!$user->hasPermission("MACHINEMANAGER_EDIT")) {
header("Location: ./app.php?msg=no_permission");
die();
}
$editing = false;
if (empty($_GET['id']) || !Machine::exists($_GET['id'])) {
header("Location: ./app.php?msg=invalid_parameters");
}
$machine = new Machine($_GET['id']);
$form = new FormBuilder("Add Event", "fas fa-history", "action.php", "POST");
$form->setID("editmachine");
$form->addHiddenInput("action", "addevent");
$form->addHiddenInput("source", "viewmachine");
$form->addHiddenInput("machine", htmlspecialchars($_GET['id']));
$eventtypes = Event::getTypes();
$eventselect = [
"" => ""
];
foreach ($eventtypes as $key => $val) {
$optgroup = trim(str_replace("[]", "", $key));
$valprepend = strpos($key, " []") !== false ? "" : trim($key);
foreach ($val as $v) {
if (empty($valprepend)) {
$vpre = "";
} else if (empty($v)) {
$vpre = $valprepend;
} else {
$vpre = $valprepend . ": ";
}
if (empty($v)) {
$eventselect[$optgroup][$vpre] = "[$vpre Other]";
} else {
$eventselect[$optgroup][$vpre . $v] = $v;
}
}
}
$form->addInput("event", "", "select", true, null, $eventselect, "Event", "fas fa-list");
$form->addInput("date", date("Y-m-d"), "date", true, null, null, "Date", "fas fa-calendar");
$form->addInput("time", date("H:i"), "time", true, null, null, "Time", "fas fa-clock");
$form->addInput("privatenotes", "", "textarea", false, null, null, "Private Notes", "fas fa-comment-dots", 6, 0, 10000);
$form->addInput("publicnotes", "", "textarea", false, null, null, "Public Notes", "far fa-comment-dots", 6, 0, 10000);
$form->addButton("Save", "fas fa-save", null, "submit", "savebtn");
$form->generate();