diff --git a/action.php b/action.php index 122dddf..9f79d52 100644 --- a/action.php +++ b/action.php @@ -39,6 +39,7 @@ switch ($VARS['action']) { $machine = new Machine($VARS['id']); + $machine->setType($VARS["type"]); $machine->setModel($VARS['model']); $machine->setClientID($VARS['client']); $machine->setOS($VARS['os']); diff --git a/database.mwb b/database.mwb index d1bf12b..ba250e8 100644 Binary files a/database.mwb and b/database.mwb differ diff --git a/langs/en/titles.json b/langs/en/titles.json index fc170dd..65dbb15 100644 --- a/langs/en/titles.json +++ b/langs/en/titles.json @@ -4,5 +4,6 @@ "Machines": "Machines", "Clients": "Clients", "Machine Info": "Machine Info", + "Device Info": "Device Info", "Tracking Info": "Tracking Info" } diff --git a/lib/Client.lib.php b/lib/Client.lib.php index be98587..3e552e7 100644 --- a/lib/Client.lib.php +++ b/lib/Client.lib.php @@ -150,7 +150,7 @@ class Client implements JsonSerializable { } if ($this->exists) { - $client = NinjaClient::find($id); + $client = NinjaClient::find($this->id); $client->name = $this->getName(); } else { $client = new NinjaClient($this->getEmail(), '', '', $this->getName()); diff --git a/lib/Machine.lib.php b/lib/Machine.lib.php index 826de86..3eb0073 100644 --- a/lib/Machine.lib.php +++ b/lib/Machine.lib.php @@ -7,6 +7,9 @@ class Machine implements JsonSerializable { private $machineid = ""; + private $icon = "fas fa-desktop"; + private $typeid = 14; + private $typelabel = "Machine"; private $machine = []; private $events = []; private $components = []; @@ -17,7 +20,11 @@ class Machine implements JsonSerializable { $this->machineid = $machineid; if (Machine::exists($machineid)) { $this->exists = true; - $this->machine = $database->get('machines', ['model', 'condition', 'price', 'os', 'serial', 'manufacturer', 'clientid', 'privatenotes', 'publicnotes'], ['machineid' => $machineid]); + $this->machine = $database->get('machines', ['type', 'model', 'condition', 'price', 'os', 'serial', 'manufacturer', 'clientid', 'privatenotes', 'publicnotes'], ['machineid' => $machineid]); + $typeinfo = $database->get("machine_types", ["machinetypeid (id)", "typename (label)", "icon"], ["machinetypeid" => $this->machine["type"]]); + $this->icon = $typeinfo["icon"]; + $this->typeid = $typeinfo["id"]; + $this->typelabel = $typeinfo["label"]; $events = $database->select('events', 'historyid', ['machineid' => $machineid, "ORDER" => ["date" => "DESC"]]); foreach ($events as $e) { $this->events[] = new Event($e); @@ -35,6 +42,11 @@ class Machine implements JsonSerializable { return [ "status" => "OK", "id" => $this->machineid, + "icon" => $this->icon, + "type" => [ + "id" => $this->typeid, + "label" => $this->typelabel + ], "info" => $this->machine, "events" => $this->events, "components" => $this->components, @@ -132,6 +144,18 @@ class Machine implements JsonSerializable { return ""; } + public function getType(): int { + return $this->typeid; + } + + public function getTypeLabel(): string { + return $this->typelabel; + } + + public function getIcon(): string { + return $this->icon; + } + public function getModel(): string { if (!empty($this->machine["model"])) { return $this->machine["model"]; @@ -196,6 +220,16 @@ class Machine implements JsonSerializable { $this->machine["clientid"] = $id; } + public function setType(int $typeid) { + global $database; + $this->typeid = $typeid; + $this->machine["type"] = $typeid; + + $typeinfo = $database->get("machine_types", ["machinetypeid (id)", "typename (label)", "icon"], ["machinetypeid" => $typeid]); + $this->icon = $typeinfo["icon"]; + $this->typelabel = $typeinfo["label"]; + } + public function setModel(string $model) { $this->machine["model"] = $model; } diff --git a/pages/editmachine.php b/pages/editmachine.php index 5a180b7..6274e59 100644 --- a/pages/editmachine.php +++ b/pages/editmachine.php @@ -23,7 +23,7 @@ if (!empty($_GET['arg']) && Machine::exists($_GET['arg'])) { } if ($editing) { - $form = new FormBuilder("Edit Machine #" . $machine->getID(), "fas fa-desktop", "action.php", "POST"); + $form = new FormBuilder("Edit " . $machine->getTypeLabel() . " #" . $machine->getID(), "fas fa-desktop", "action.php", "POST"); } else { $form = new FormBuilder("Add Machine", "fas fa-desktop", "action.php", "POST"); } @@ -39,12 +39,19 @@ $clients = [ foreach (Clients::getAll() as $c) { $clients[$c->getID()] = $c->getName(); } +$typelist = [ + "" => "" +]; +foreach ($database->select("machine_types", ["machinetypeid (id)", "typename (name)"]) as $t) { + $typelist[$t["id"]] = $t["name"]; +} if ($editing) { $form->addHiddenInput("id", $machine->getID()); } else { $form->addInput("id", $machine->getID(), "text", true, null, null, "Machine ID", "fas fa-desktop", 4, 1, 20); } +$form->addInput("type", $machine->getType(), "select", true, null, $typelist, "Machine Type", "fas fa-desktop"); $form->addInput("client", $machine->getClientID(), "select", false, null, $clients, "Client", "fas fa-user"); $form->addInput("model", $machine->getModel(), "text", false, null, null, "Model", "fas fa-hashtag", 4, 0, 200); $form->addInput("os", $machine->getOS(), "text", false, null, null, "OS/Software", "fas fa-hdd", 4, 0, 200); diff --git a/pages/printlabel.php b/pages/printlabel.php index 74e5863..f07b65b 100644 --- a/pages/printlabel.php +++ b/pages/printlabel.php @@ -45,7 +45,7 @@ $pdfurl = "./print/print.php?labeltype=$labeltype&id=$machineid";
diff --git a/pages/viewmachine.php b/pages/viewmachine.php index 1dec957..8d2c0d8 100644 --- a/pages/viewmachine.php +++ b/pages/viewmachine.php @@ -27,7 +27,7 @@ $machine = new Machine($machineid);

- get("Machine"); ?> #getID()); ?> + getTypeLabel(); ?> #getID()); ?>
hasPermission("MACHINEMANAGER_EDIT")) { ?>
@@ -42,7 +42,7 @@ $machine = new Machine($machineid);
-
Machine Info:
+
Device Info:
get("OS/Software"); ?>: getOS()); ?> diff --git a/print/print.php b/print/print.php index 5f851db..455df0c 100644 --- a/print/print.php +++ b/print/print.php @@ -45,6 +45,8 @@ $mergedata = [ "id" => $machine->getID(), "link" => str_replace("{{id}}", $machine->getID(), $SETTINGS["branding"]["trackinglink"]), "price" => number_format($machine->getPrice(), 2), + "devicetype" => $machine->getTypeLabel(), + "devicetype_lowercase" => strtolower($machine->getTypeLabel()), "serial" => $machine->getSerial(), "model" => $machine->getModel(), "os" => $machine->getOS(), diff --git a/print/templates/machineid.glabels b/print/templates/machineid.glabels index 91e7b01..a5eeab9 100644 Binary files a/print/templates/machineid.glabels and b/print/templates/machineid.glabels differ diff --git a/print/templates/machineidanonymous.glabels b/print/templates/machineidanonymous.glabels index c1a067c..01268a8 100644 Binary files a/print/templates/machineidanonymous.glabels and b/print/templates/machineidanonymous.glabels differ diff --git a/print/templates/pickupslip.glabels b/print/templates/pickupslip.glabels index 25c26a0..cae948b 100644 Binary files a/print/templates/pickupslip.glabels and b/print/templates/pickupslip.glabels differ diff --git a/public/index.php b/public/index.php index 08735dc..47e7538 100644 --- a/public/index.php +++ b/public/index.php @@ -130,14 +130,14 @@ if (isset($_GET["backgroundcolor"]) && !empty($_GET["backgroundcolor"]) && preg_

- get("Machine Info"); ?> + get("Device Info"); ?>

-

No machine with ID could be found.

+

No device with ID could be found.

@@ -164,7 +164,7 @@ if (isset($_GET["backgroundcolor"]) && !empty($_GET["backgroundcolor"]) && preg_

- get("Machine Info"); ?> + getTypeLabel(); ?> Info

@@ -267,7 +267,7 @@ if (isset($_GET["backgroundcolor"]) && !empty($_GET["backgroundcolor"]) && preg_
getComponents(); if (count($components) > 0) { @@ -337,7 +337,7 @@ if (isset($_GET["backgroundcolor"]) && !empty($_GET["backgroundcolor"]) && preg_

- Look up another machine: + Look up another device:

" required /> diff --git a/settings.template.php b/settings.template.php index 2480965..6879b13 100644 --- a/settings.template.php +++ b/settings.template.php @@ -37,9 +37,9 @@ $SETTINGS = [ // Name of the app. "site_title" => "MachineManager", "branding" => [ - "machineidnumber" => "Netsyms machine ID number", - "shortmachineid" => "Machine ID Number", - "publictitle" => "Machine Lookup", + "machineidnumber" => "Netsyms device ID number, machine ID number", + "shortmachineid" => "Device ID Number", + "publictitle" => "Device Lookup", "trackinglink" => "https://qr.ntsm.io/?t=mid&q={{id}}" ], // Settings for connecting to the AccountHub server.