From df6a3b7e1da98c2c413a36581f765e6b9bf624cc Mon Sep 17 00:00:00 2001
From: Skylar Ittner
- Enter a , serial number, or tracking code.
-
- Enter a , serial number, or tracking code.
- No device with ID
- Enter a , serial number, or tracking code.
- {id} could be found.",
+ "Component exist but isn't attached to a machine": "This component ID exists in the system but has no associated device."
+}
diff --git a/langs/en/events.json b/langs/en/events.json
index 405af31..2e35e5c 100644
--- a/langs/en/events.json
+++ b/langs/en/events.json
@@ -1,5 +1,6 @@
{
"Date": "Date",
"Technician": "Technician",
- "Event": "Event"
+ "Event": "Event",
+ "event html label": "{name} on {date}"
}
diff --git a/langs/en/labels.json b/langs/en/labels.json
index 1742298..0520a41 100644
--- a/langs/en/labels.json
+++ b/langs/en/labels.json
@@ -3,6 +3,6 @@
"Private Notes": "Private Notes",
"Machine ID": "Machine ID",
"Back": "Back",
- "Components": "Components"
-
+ "Components": "Components",
+ "Component": "Component"
}
\ No newline at end of file
diff --git a/langs/en/machines.json b/langs/en/machines.json
index ba7ff05..a6c577c 100644
--- a/langs/en/machines.json
+++ b/langs/en/machines.json
@@ -14,5 +14,6 @@
"Tested On": "Tested On",
"Capacity": "Capacity",
"Last Event": "Last Event",
- "Client": "Client"
+ "Client": "Client",
+ "OS": "OS"
}
diff --git a/langs/en/public.json b/langs/en/public.json
new file mode 100644
index 0000000..e8fc5c2
--- /dev/null
+++ b/langs/en/public.json
@@ -0,0 +1,4 @@
+{
+ "Get Info": "Get Info",
+ "Number": "Number"
+}
diff --git a/lib/Component.lib.php b/lib/Component.lib.php
index ebf15f4..176ab5e 100644
--- a/lib/Component.lib.php
+++ b/lib/Component.lib.php
@@ -89,6 +89,69 @@ class Component implements JsonSerializable {
return [];
}
+ /**
+ * Render the component's info to HTML
+ * @param bool $public
+ */
+ public function toHTML(bool $public = true): string {
+ global $Strings;
+ $func = function($param) {
+ return $param;
+ };
+ $line = function($type) use ($public): string {
+ global $Strings, $SETTINGS;
+ if ($type == "TestedDate") {
+ if (!empty($this->getTestedDate())) {
+ return "" . $Strings->get("Tested On", false) . ": " . date($SETTINGS["date_format"], strtotime($this->getTestedDate())) . "
";
+ }
+ return "";
+ }
+ if ($type == "Price") {
+ if (!empty($this->getPrice())) {
+ return "" . $Strings->get("Price", false) . ": $" . number_format($this->getPrice(), 2) . "
";
+ }
+ return "";
+ }
+ if ($type == "PublicNotes") {
+ if (!empty($this->getPublicNotes())) {
+ return "
";
+ };
+ $html = "";
+ if ($public == false) {
+ $html .= <<
+ Detach
+ Edit
+
+HTML;
+ }
+ $html .= <<{$func($this->getTypeName())}
+ {$line("Model")}
+ {$line("Capacity")}
+ {$line("Serial")}
+ {$line("TestedDate")}
+ {$line("Price")}
+ {$line("Manufacturer")}
+ {$line("PrivateNotes")}
+ {$line("PublicNotes")}
+HTML;
+ return $html;
+ }
+
public function jsonSerialize() {
return $this->toArray();
}
diff --git a/lib/Event.lib.php b/lib/Event.lib.php
index a7b4b59..5e09434 100644
--- a/lib/Event.lib.php
+++ b/lib/Event.lib.php
@@ -51,7 +51,7 @@ class Event implements JsonSerializable {
}
public static function getTypes() {
- $list = json_decode(file_get_contents(__DIR__ . '/events.json'), true);
+ $list = json_decode(file_get_contents(__DIR__ . '/../custom/events.json'), true);
return $list;
}
@@ -117,6 +117,30 @@ class Event implements JsonSerializable {
return [];
}
+ /**
+ * Render the events's info to HTML
+ * @param bool $public
+ */
+ public function toHTML(bool $public = true): string {
+ global $Strings, $SETTINGS;
+
+ $html = $Strings->build("event html label", [
+ "name" => $this->getName(),
+ "date" => date($SETTINGS["datetime_format"], strtotime($this->getDate()))
+ ], false);
+ $html .= "
\n";
+ if (!empty($this->getTechUID()) && $public == false) {
+ $html .= "" . $Strings->get("Technician", false) . ": " . htmlspecialchars((new User($this->getTechUID()))->getName()) . "
\n";
+ }
+ if (!empty($this->getPublicNotes())) {
+ $html .= "
";
+ $rtn .= "
";
+ }
+ if (!empty($client->getEmail())) {
+ $rtn .= "Email: " . $client->getEmail() . "
";
+ }
+ if (!empty($client->getBillingAddress())) {
+ $rtn .= "" . $Strings->get("Billing Address", false)
+ . ":
"
+ . str_replace("\n", "\n
", htmlspecialchars($client->getBillingAddress()))
+ . "
";
+ }
+ if (!empty($client->getMailingAddress())) {
+ $rtn .= "" . $Strings->get("Mailing Address", false)
+ . ":
"
+ . str_replace("\n", "\n
", htmlspecialchars($client->getMailingAddress()))
+ . "
";
+ }
+ $rtn .= "
";
+ }
+ return "";
+ }
+ if ($type == "PublicNotes") {
+ if (!empty($this->getPublicNotes())) {
+ return "" . ($public ? $Strings->get("Notes", false) : $Strings->get("Public Notes", false)) . ":
";
+ }
+ if (empty($this->{"get$type"}())) {
+ return "";
+ }
+ return "" . $Strings->get($type, false) . ": " . htmlspecialchars($this->{"get$type"}()) . "
";
+ };
+
+ $props = ["Client", "OS", "Serial", "Manufacturer", "Model", "Condition", "Price", "PrivateNotes", "PublicNotes"];
+
+ if ($public) {
+ $props = ["ID"] + $props;
+ }
+
+ $html = 'Device Info:
-
-
-
- getBillingAddress())) { ?>
- Billing address:
", htmlspecialchars($client->getBillingAddress())); ?>
-
-
- getMailingAddress())) { ?>
- Mailing address:
", htmlspecialchars($client->getMailingAddress())); ?>
-
-
-
\n";
- if (!empty($h->getTechUID())) {
- echo "Technician: " . htmlspecialchars((new User($h->getTechUID()))->getName()) . "
\n";
- }
- if (!empty($h->getPublicNotes())) {
- echo "
", htmlspecialchars($h->getPublicNotes())) . "
", htmlspecialchars($h->getPrivateNotes())) . "
- getModel())) {
- ?>
- get("Model"); ?>: getModel()); ?>
- getCapacity())) {
- ?>
- get("Capacity"); ?>: getCapacity()); ?>
- getSerial())) {
- ?>
- get("Serial"); ?>: getSerial()); ?>
- getManufacturer())) {
- ?>
- get("Manufacturer"); ?>: getManufacturer()); ?>
- getTestedDate())) {
- ?>
- get("Tested On"); ?>: getTestedDate())); ?>
- getPrice())) {
- ?>
- get("Price"); ?>: $getPrice(), 2); ?>
- getPublicNotes())) {
- ?>
-
-
- ';
+ echo '
';
+ if (is_array($body)) {
+ foreach ($body as $b) {
+ if (empty($b)) {
+ continue;
+ }
+ echo '
-
- is not valid. Please try re-typing it.' . htmlspecialchars($_GET['id']) . ' is not valid. Please try re-typing it.
-
- History:
-
-
-
-
';
+ $html .= date($SETTINGS["datetime_format"], $his["date"]) . '
';
+ $html .= implode(" ", $his["location"]);
+ $html .= '
-
- could be found.
- Look up another device: -
- -- Look up another device: -
- -