Add API to get machine form fields without looking up machine

master
Skylar Ittner 4 years ago
parent 35714f96b9
commit a28062ae8a

@ -23,7 +23,7 @@ if (!empty($VARS["id"])) {
$user = getRequestUser();
if ($VARS["action"] != "lookup") {
if ($VARS["action"] != "lookup" && $VARS["action"] != "getmachineformfields") {
if (!$user->hasPermission("MACHINEMANAGER_EDIT")) {
http_response_code(403);

@ -60,6 +60,10 @@ $APIS = [
"publicnotes (optional)" => "string"
]
],
"getmachineformfields" => [
"load" => "machine.php",
"vars" => []
],
"getclient" => [
"load" => "client.php",
"vars" => [

@ -148,7 +148,59 @@ class Machine implements JsonSerializable {
]
];
}
return [];
return [
"status" => "OK",
"id" => "",
"icon" => "",
"type" => [
"id" => "",
"label" => ""
],
"clientinfo" => [],
"info" => [],
"events" => [],
"components" => [],
"formdata" => [
"options" => [
"clientid" => ["" => ""] + Clients::getAllAsIDNameArray(),
"type" => Machine::getTypeList()
],
"inputtypes" => [
"model" => "text",
"condition" => "number",
"price" => "number",
"os" => "text",
"serial" => "text",
"manufacturer" => "text",
"clientid" => "select",
"privatenotes" => "textarea",
"publicnotes" => "textarea",
"type" => "select"
],
"labels" => [
"model" => $Strings->get("Model", false),
"condition" => $Strings->get("Condition", false),
"price" => $Strings->get("Price", false),
"os" => $Strings->get("OS/Software", false),
"serial" => $Strings->get("Serial", false),
"manufacturer" => $Strings->get("Manufacturer", false),
"clientid" => $Strings->get("Client", false),
"privatenotes" => $Strings->get("Private Notes", false),
"publicnotes" => $Strings->get("Public Notes", false),
"type" => $Strings->get("Type", false)
],
"icons" => [
"model" => "fas fa-hashtag",
"condition" => "fas fa-star-half-alt",
"price" => "fas fa-money-bill-wave",
"os" => "fas fa-hdd",
"serial" => "fas fa-barcode",
"manufacturer" => "fas fa-industry",
"privatenotes" => "fas fa-comment-dots",
"publicnotes" => "far fa-comment-dots"
]
]
];
}
public function toHTMLListGroup(bool $public = true): string {
@ -233,7 +285,7 @@ class Machine implements JsonSerializable {
return "";
}
if ($type == "ID") {
return "<b>" . $publicsettings["ID number label"] . ":</b> " . htmlspecialchars($this->getID()) . "<br />";
return "<b>" . $publicsettings["ID number label"] . ":</b> " . htmlspecialchars($this->getID()) . "<br />";
}
if (empty($this->{"get$type"}())) {
return "";

Loading…
Cancel
Save