Add machine types and icons (laptop, phone, drive, etc)

master
Skylar Ittner 4 years ago
parent c042a53581
commit 6a2fa51570

@ -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']);

Binary file not shown.

@ -4,5 +4,6 @@
"Machines": "Machines",
"Clients": "Clients",
"Machine Info": "Machine Info",
"Device Info": "Device Info",
"Tracking Info": "Tracking Info"
}

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

@ -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;
}

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

@ -45,7 +45,7 @@ $pdfurl = "./print/print.php?labeltype=$labeltype&id=$machineid";
<div class="d-flex">
<ul class="nav nav-tabs">
<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 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>
@ -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>
</li>
<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>
</ul>
<div class="ml-auto">

@ -27,7 +27,7 @@ $machine = new Machine($machineid);
<div class="card">
<h3 class="card-header d-flex">
<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>
<?php if ($user->hasPermission("MACHINEMANAGER_EDIT")) { ?>
<div class="ml-auto">
@ -42,7 +42,7 @@ $machine = new Machine($machineid);
<div class="card-body">
<div class="row">
<div class="col-sm-6 mb-3">
<h6>Machine Info:</h6>
<h6>Device Info:</h6>
<div class="list-group">
<div class="list-group-item">
<b><?php $Strings->get("OS/Software"); ?></b>: <?php echo htmlspecialchars($machine->getOS()); ?>

@ -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(),

Binary file not shown.

@ -130,14 +130,14 @@ if (isset($_GET["backgroundcolor"]) && !empty($_GET["backgroundcolor"]) && preg_
<div class="card">
<h3 class="card-header d-flex">
<div>
<i class="fas fa-desktop"></i> <?php $Strings->get("Machine Info"); ?>
<i class="fas fa-desktop"></i> <?php $Strings->get("Device Info"); ?>
</div>
</h3>
<div class="card-body">
<?php
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
}
?>
@ -164,7 +164,7 @@ if (isset($_GET["backgroundcolor"]) && !empty($_GET["backgroundcolor"]) && preg_
<div class="card">
<h3 class="card-header d-flex">
<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>
</h3>
<div class="card-body">
@ -267,7 +267,7 @@ if (isset($_GET["backgroundcolor"]) && !empty($_GET["backgroundcolor"]) && preg_
</div>
<?php
}
$components = $machine->getComponents();
if (count($components) > 0) {
@ -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"])) { ?>
<div class="card-body">
<p>
Look up another machine:
Look up another device:
</p>
<form method="GET">
<input type="text" name="id" class="form-control" placeholder="<?php echo $SETTINGS["branding"]["shortmachineid"]; ?>" required />

@ -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.

Loading…
Cancel
Save