Add machine types and icons (laptop, phone, drive, etc)
This commit is contained in:
parent
c042a53581
commit
6a2fa51570
@ -39,6 +39,7 @@ switch ($VARS['action']) {
|
|||||||
|
|
||||||
$machine = new Machine($VARS['id']);
|
$machine = new Machine($VARS['id']);
|
||||||
|
|
||||||
|
$machine->setType($VARS["type"]);
|
||||||
$machine->setModel($VARS['model']);
|
$machine->setModel($VARS['model']);
|
||||||
$machine->setClientID($VARS['client']);
|
$machine->setClientID($VARS['client']);
|
||||||
$machine->setOS($VARS['os']);
|
$machine->setOS($VARS['os']);
|
||||||
|
BIN
database.mwb
BIN
database.mwb
Binary file not shown.
@ -4,5 +4,6 @@
|
|||||||
"Machines": "Machines",
|
"Machines": "Machines",
|
||||||
"Clients": "Clients",
|
"Clients": "Clients",
|
||||||
"Machine Info": "Machine Info",
|
"Machine Info": "Machine Info",
|
||||||
|
"Device Info": "Device Info",
|
||||||
"Tracking Info": "Tracking Info"
|
"Tracking Info": "Tracking Info"
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ class Client implements JsonSerializable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($this->exists) {
|
if ($this->exists) {
|
||||||
$client = NinjaClient::find($id);
|
$client = NinjaClient::find($this->id);
|
||||||
$client->name = $this->getName();
|
$client->name = $this->getName();
|
||||||
} else {
|
} else {
|
||||||
$client = new NinjaClient($this->getEmail(), '', '', $this->getName());
|
$client = new NinjaClient($this->getEmail(), '', '', $this->getName());
|
||||||
|
@ -7,6 +7,9 @@
|
|||||||
class Machine implements JsonSerializable {
|
class Machine implements JsonSerializable {
|
||||||
|
|
||||||
private $machineid = "";
|
private $machineid = "";
|
||||||
|
private $icon = "fas fa-desktop";
|
||||||
|
private $typeid = 14;
|
||||||
|
private $typelabel = "Machine";
|
||||||
private $machine = [];
|
private $machine = [];
|
||||||
private $events = [];
|
private $events = [];
|
||||||
private $components = [];
|
private $components = [];
|
||||||
@ -17,7 +20,11 @@ class Machine implements JsonSerializable {
|
|||||||
$this->machineid = $machineid;
|
$this->machineid = $machineid;
|
||||||
if (Machine::exists($machineid)) {
|
if (Machine::exists($machineid)) {
|
||||||
$this->exists = true;
|
$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"]]);
|
$events = $database->select('events', 'historyid', ['machineid' => $machineid, "ORDER" => ["date" => "DESC"]]);
|
||||||
foreach ($events as $e) {
|
foreach ($events as $e) {
|
||||||
$this->events[] = new Event($e);
|
$this->events[] = new Event($e);
|
||||||
@ -35,6 +42,11 @@ class Machine implements JsonSerializable {
|
|||||||
return [
|
return [
|
||||||
"status" => "OK",
|
"status" => "OK",
|
||||||
"id" => $this->machineid,
|
"id" => $this->machineid,
|
||||||
|
"icon" => $this->icon,
|
||||||
|
"type" => [
|
||||||
|
"id" => $this->typeid,
|
||||||
|
"label" => $this->typelabel
|
||||||
|
],
|
||||||
"info" => $this->machine,
|
"info" => $this->machine,
|
||||||
"events" => $this->events,
|
"events" => $this->events,
|
||||||
"components" => $this->components,
|
"components" => $this->components,
|
||||||
@ -132,6 +144,18 @@ class Machine implements JsonSerializable {
|
|||||||
return "";
|
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 {
|
public function getModel(): string {
|
||||||
if (!empty($this->machine["model"])) {
|
if (!empty($this->machine["model"])) {
|
||||||
return $this->machine["model"];
|
return $this->machine["model"];
|
||||||
@ -196,6 +220,16 @@ class Machine implements JsonSerializable {
|
|||||||
$this->machine["clientid"] = $id;
|
$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) {
|
public function setModel(string $model) {
|
||||||
$this->machine["model"] = $model;
|
$this->machine["model"] = $model;
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@ if (!empty($_GET['arg']) && Machine::exists($_GET['arg'])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($editing) {
|
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 {
|
} else {
|
||||||
$form = new FormBuilder("Add Machine", "fas fa-desktop", "action.php", "POST");
|
$form = new FormBuilder("Add Machine", "fas fa-desktop", "action.php", "POST");
|
||||||
}
|
}
|
||||||
@ -39,12 +39,19 @@ $clients = [
|
|||||||
foreach (Clients::getAll() as $c) {
|
foreach (Clients::getAll() as $c) {
|
||||||
$clients[$c->getID()] = $c->getName();
|
$clients[$c->getID()] = $c->getName();
|
||||||
}
|
}
|
||||||
|
$typelist = [
|
||||||
|
"" => ""
|
||||||
|
];
|
||||||
|
foreach ($database->select("machine_types", ["machinetypeid (id)", "typename (name)"]) as $t) {
|
||||||
|
$typelist[$t["id"]] = $t["name"];
|
||||||
|
}
|
||||||
|
|
||||||
if ($editing) {
|
if ($editing) {
|
||||||
$form->addHiddenInput("id", $machine->getID());
|
$form->addHiddenInput("id", $machine->getID());
|
||||||
} else {
|
} else {
|
||||||
$form->addInput("id", $machine->getID(), "text", true, null, null, "Machine ID", "fas fa-desktop", 4, 1, 20);
|
$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("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("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);
|
$form->addInput("os", $machine->getOS(), "text", false, null, null, "OS/Software", "fas fa-hdd", 4, 0, 200);
|
||||||
|
@ -45,7 +45,7 @@ $pdfurl = "./print/print.php?labeltype=$labeltype&id=$machineid";
|
|||||||
<div class="d-flex">
|
<div class="d-flex">
|
||||||
<ul class="nav nav-tabs">
|
<ul class="nav nav-tabs">
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link<?php echo ($labeltype == "machineid" ? " active" : "") ?>" href="./app.php?page=printlabel&id=<?php echo $machine->getID(); ?>">Machine ID Label</a>
|
<a class="nav-link<?php echo ($labeltype == "machineid" ? " active" : "") ?>" href="./app.php?page=printlabel&id=<?php echo $machine->getID(); ?>">ID Label</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link<?php echo ($labeltype == "pickupslip" ? " active" : "") ?>" href="./app.php?page=printlabel&id=<?php echo $machine->getID(); ?>&labeltype=pickupslip">Pickup Slip</a>
|
<a class="nav-link<?php echo ($labeltype == "pickupslip" ? " active" : "") ?>" href="./app.php?page=printlabel&id=<?php echo $machine->getID(); ?>&labeltype=pickupslip">Pickup Slip</a>
|
||||||
@ -54,7 +54,7 @@ $pdfurl = "./print/print.php?labeltype=$labeltype&id=$machineid";
|
|||||||
<a class="nav-link<?php echo ($labeltype == "doortag" ? " active" : "") ?>" href="./app.php?page=printlabel&id=<?php echo $machine->getID(); ?>&labeltype=doortag">Door Tag</a>
|
<a class="nav-link<?php echo ($labeltype == "doortag" ? " active" : "") ?>" href="./app.php?page=printlabel&id=<?php echo $machine->getID(); ?>&labeltype=doortag">Door Tag</a>
|
||||||
</li>
|
</li>
|
||||||
<li class="nav-item">
|
<li class="nav-item">
|
||||||
<a class="nav-link<?php echo ($labeltype == "machineidanonymous" ? " active" : "") ?>" href="./app.php?page=printlabel&id=<?php echo $machine->getID(); ?>&labeltype=machineidanonymous">Machine ID Label (No "Property Of")</a>
|
<a class="nav-link<?php echo ($labeltype == "machineidanonymous" ? " active" : "") ?>" href="./app.php?page=printlabel&id=<?php echo $machine->getID(); ?>&labeltype=machineidanonymous">ID Label (No "Property Of")</a>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div class="ml-auto">
|
<div class="ml-auto">
|
||||||
|
@ -27,7 +27,7 @@ $machine = new Machine($machineid);
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<h3 class="card-header d-flex">
|
<h3 class="card-header d-flex">
|
||||||
<div>
|
<div>
|
||||||
<i class="fas fa-desktop"></i> <?php $Strings->get("Machine"); ?> #<?php echo htmlspecialchars($machine->getID()); ?>
|
<i class="<?php echo $machine->getIcon(); ?>"></i> <?php echo $machine->getTypeLabel(); ?> #<?php echo htmlspecialchars($machine->getID()); ?>
|
||||||
</div>
|
</div>
|
||||||
<?php if ($user->hasPermission("MACHINEMANAGER_EDIT")) { ?>
|
<?php if ($user->hasPermission("MACHINEMANAGER_EDIT")) { ?>
|
||||||
<div class="ml-auto">
|
<div class="ml-auto">
|
||||||
@ -42,7 +42,7 @@ $machine = new Machine($machineid);
|
|||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-6 mb-3">
|
<div class="col-sm-6 mb-3">
|
||||||
<h6>Machine Info:</h6>
|
<h6>Device Info:</h6>
|
||||||
<div class="list-group">
|
<div class="list-group">
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
<b><?php $Strings->get("OS/Software"); ?></b>: <?php echo htmlspecialchars($machine->getOS()); ?>
|
<b><?php $Strings->get("OS/Software"); ?></b>: <?php echo htmlspecialchars($machine->getOS()); ?>
|
||||||
|
@ -45,6 +45,8 @@ $mergedata = [
|
|||||||
"id" => $machine->getID(),
|
"id" => $machine->getID(),
|
||||||
"link" => str_replace("{{id}}", $machine->getID(), $SETTINGS["branding"]["trackinglink"]),
|
"link" => str_replace("{{id}}", $machine->getID(), $SETTINGS["branding"]["trackinglink"]),
|
||||||
"price" => number_format($machine->getPrice(), 2),
|
"price" => number_format($machine->getPrice(), 2),
|
||||||
|
"devicetype" => $machine->getTypeLabel(),
|
||||||
|
"devicetype_lowercase" => strtolower($machine->getTypeLabel()),
|
||||||
"serial" => $machine->getSerial(),
|
"serial" => $machine->getSerial(),
|
||||||
"model" => $machine->getModel(),
|
"model" => $machine->getModel(),
|
||||||
"os" => $machine->getOS(),
|
"os" => $machine->getOS(),
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -130,14 +130,14 @@ if (isset($_GET["backgroundcolor"]) && !empty($_GET["backgroundcolor"]) && preg_
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<h3 class="card-header d-flex">
|
<h3 class="card-header d-flex">
|
||||||
<div>
|
<div>
|
||||||
<i class="fas fa-desktop"></i> <?php $Strings->get("Machine Info"); ?>
|
<i class="fas fa-desktop"></i> <?php $Strings->get("Device Info"); ?>
|
||||||
</div>
|
</div>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<?php
|
<?php
|
||||||
if (!empty($_GET["id"])) {
|
if (!empty($_GET["id"])) {
|
||||||
?>
|
?>
|
||||||
<p class="text-danger">No machine with ID <code><?php echo htmlspecialchars($_GET['id']); ?></code> could be found.</p>
|
<p class="text-danger">No device with ID <code><?php echo htmlspecialchars($_GET['id']); ?></code> could be found.</p>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
@ -164,7 +164,7 @@ if (isset($_GET["backgroundcolor"]) && !empty($_GET["backgroundcolor"]) && preg_
|
|||||||
<div class="card">
|
<div class="card">
|
||||||
<h3 class="card-header d-flex">
|
<h3 class="card-header d-flex">
|
||||||
<div>
|
<div>
|
||||||
<i class="fas fa-desktop"></i> <?php $Strings->get("Machine Info"); ?>
|
<i class="<?php echo $machine->getIcon(); ?>"></i> <?php echo $machine->getTypeLabel(); ?> Info
|
||||||
</div>
|
</div>
|
||||||
</h3>
|
</h3>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
@ -337,7 +337,7 @@ if (isset($_GET["backgroundcolor"]) && !empty($_GET["backgroundcolor"]) && preg_
|
|||||||
<?php /* Hide this box if we're embedded in another page */ if (!isset($_GET["embed"])) { ?>
|
<?php /* Hide this box if we're embedded in another page */ if (!isset($_GET["embed"])) { ?>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
<p>
|
<p>
|
||||||
Look up another machine:
|
Look up another device:
|
||||||
</p>
|
</p>
|
||||||
<form method="GET">
|
<form method="GET">
|
||||||
<input type="text" name="id" class="form-control" placeholder="<?php echo $SETTINGS["branding"]["shortmachineid"]; ?>" required />
|
<input type="text" name="id" class="form-control" placeholder="<?php echo $SETTINGS["branding"]["shortmachineid"]; ?>" required />
|
||||||
|
@ -37,9 +37,9 @@ $SETTINGS = [
|
|||||||
// Name of the app.
|
// Name of the app.
|
||||||
"site_title" => "MachineManager",
|
"site_title" => "MachineManager",
|
||||||
"branding" => [
|
"branding" => [
|
||||||
"machineidnumber" => "Netsyms machine ID number",
|
"machineidnumber" => "Netsyms device ID number, machine ID number",
|
||||||
"shortmachineid" => "Machine ID Number",
|
"shortmachineid" => "Device ID Number",
|
||||||
"publictitle" => "Machine Lookup",
|
"publictitle" => "Device Lookup",
|
||||||
"trackinglink" => "https://qr.ntsm.io/?t=mid&q={{id}}"
|
"trackinglink" => "https://qr.ntsm.io/?t=mid&q={{id}}"
|
||||||
],
|
],
|
||||||
// Settings for connecting to the AccountHub server.
|
// Settings for connecting to the AccountHub server.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user