master
Skylar Ittner 4 years ago
parent 1801be0480
commit 458cf93b34

@ -101,6 +101,9 @@ switch ($VARS['action']) {
$component->save();
if (empty($VARS["machine"])) {
returnToSender("component_saved");
}
returnToSender("component_saved", $component->getMachineID());
case "addevent":
$user = new User($_SESSION['uid']);

@ -20,16 +20,18 @@ $machine = null;
if (!empty($VARS["arg"]) && Component::exists($VARS["arg"])) {
$editing = true;
$component = new Component($VARS["arg"]);
$machine = new Machine($component->getMachineID());
} else if (!empty($VARS["id"]) && Component::exists($VARS["id"])) {
$editing = true;
$component = new Component($VARS["id"]);
$machine = new Machine($component->getMachineID());
} else {
$component = Component::create();
$editing = false;
}
if ($editing && !empty($component->getMachineID())) {
$machine = new Machine($component->getMachineID());
}
if (!empty($VARS['machine']) && Machine::exists($VARS['machine'])) {
$machine = new Machine($VARS['machine']);
$component->setMachineID($machine->getID());
@ -41,7 +43,7 @@ if ($editing) {
$form = new FormBuilder("Add Component", "fas fa-memory", "action.php", "POST");
}
$form->setID("editmachine");
$form->setID("editcomponent");
$form->addHiddenInput("action", "editcomponent");
@ -58,7 +60,7 @@ if ($editing) {
$form->addInput("id", $component->getID(), "text", true, null, null, "Component ID", "fas fa-memory", 4, 1, 20);
}
if (!is_null($machine)) {
if (!empty($machine)) {
$form->addHiddenInput("source", "viewmachine");
} else {
$form->addHiddenInput("source", "components");

Loading…
Cancel
Save