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();