Make event types configurable (JSON file) with categories, some other half-finished features
This commit is contained in:
parent
342d2669bd
commit
286d6a2917
23
action.php
23
action.php
@ -156,8 +156,29 @@ switch ($VARS['action']) {
|
||||
$client->save();
|
||||
|
||||
returnToSender("client_edited", $client->getID());
|
||||
case "editjob":
|
||||
$user = new User($_SESSION['uid']);
|
||||
if (!$user->hasPermission("MACHINEMANAGER_EDIT")) {
|
||||
returnToSender("no_permission");
|
||||
die();
|
||||
}
|
||||
|
||||
if (!empty($VARS["jobid"]) && Job::exists($VARS["jobid"])) {
|
||||
$job = new Job($VARS['jobid']);
|
||||
} else {
|
||||
$job = Job::create();
|
||||
}
|
||||
|
||||
$job->setMachineID($VARS["machineid"]);
|
||||
$job->setName($VARS["jobname"]);
|
||||
$job->setInfo($VARS["jobinfo"]);
|
||||
$job->setNotes($VARS["jobnotes"]);
|
||||
|
||||
$job->save();
|
||||
|
||||
returnToSender("job_saved", $job->getID());
|
||||
case "signout":
|
||||
session_destroy();
|
||||
header('Location: index.php?logout=1');
|
||||
die("Logged out.");
|
||||
}
|
||||
}
|
||||
|
BIN
database.mwb
BIN
database.mwb
Binary file not shown.
8
langs/en/jobs.json
Normal file
8
langs/en/jobs.json
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"Started": "Started",
|
||||
"Deadline": "Deadline",
|
||||
"Finished": "Finished",
|
||||
"Add Job": "Add Job",
|
||||
"Jobs": "Jobs",
|
||||
"Job Title": "Job Title"
|
||||
}
|
122
lib/Container.lib.php
Normal file
122
lib/Container.lib.php
Normal file
@ -0,0 +1,122 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2020 Netsyms Technologies.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
class Container {
|
||||
|
||||
public $containerid = "";
|
||||
public $barcode = "";
|
||||
public $exists = false;
|
||||
private $machines = [];
|
||||
private $components = [];
|
||||
private $others = [];
|
||||
|
||||
public function __construct($containerid) {
|
||||
global $database;
|
||||
|
||||
if ($database->has("containers", ["containerid" => $containerid])) {
|
||||
$this->exists = true;
|
||||
$info = $database->get("containers", ["barcode"], ["containerid" => $containerid]);
|
||||
$this->barcode = $info["barcode"];
|
||||
} else {
|
||||
$this->exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function save() {
|
||||
global $database;
|
||||
|
||||
if ($database->has("containers", ["containerid" => $this->containerid])) {
|
||||
$database->update("containers", [
|
||||
"barcode" => $this->barcode
|
||||
], ["containerid" => $this->containerid]);
|
||||
} else {
|
||||
$database->insert("containers", ["barcode" => $this->barcode]);
|
||||
$this->containerid = $database->id();
|
||||
$this->exists = true;
|
||||
}
|
||||
|
||||
$database->action(function ($database) {
|
||||
$database->delete("container_contents", ["containerid" => $this->containerid]);
|
||||
|
||||
foreach ($this->machines as $id) {
|
||||
$database->insert("container_contents", [
|
||||
"machineid" => $id,
|
||||
"containerid" => $this->containerid
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($this->components as $id) {
|
||||
$database->insert("container_contents", [
|
||||
"componentid" => $id,
|
||||
"containerid" => $this->containerid
|
||||
]);
|
||||
}
|
||||
|
||||
foreach ($this->others as $id) {
|
||||
$database->insert("container_contents", [
|
||||
"otherid" => $id,
|
||||
"containerid" => $this->containerid
|
||||
]);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function getMachineIDs(): array {
|
||||
return $this->machines;
|
||||
}
|
||||
|
||||
public function getComponentIDs(): array {
|
||||
return $this->components;
|
||||
}
|
||||
|
||||
public function getOtherIDs(): array {
|
||||
return $this->others;
|
||||
}
|
||||
|
||||
public function addMachine($machineid) {
|
||||
global $database;
|
||||
if ($database->has("machines", ["machineid" => $machineid])) {
|
||||
$this->machines[] = $machineid;
|
||||
} else {
|
||||
throw new Exception("No machine with ID $machineid exists.");
|
||||
}
|
||||
}
|
||||
|
||||
public function addComponent($componentid) {
|
||||
global $database;
|
||||
if ($database->has("components", ["compid" => $componentid])) {
|
||||
$this->components[] = $componentid;
|
||||
} else {
|
||||
throw new Exception("No component with ID $componentid exists.");
|
||||
}
|
||||
}
|
||||
|
||||
public function addOtherID($id) {
|
||||
$this->others[] = $id;
|
||||
}
|
||||
|
||||
public function rmMachine($machineid) {
|
||||
foreach (array_keys($this->machines, $machineid) as $id) {
|
||||
unset($this->machines[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
public function rmComponent($componentid) {
|
||||
foreach (array_keys($this->components, $componentid) as $id) {
|
||||
unset($this->components[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
public function rmOtherID($oid) {
|
||||
foreach (array_keys($this->others, $oid) as $id) {
|
||||
unset($this->others[$id]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -15,12 +15,12 @@ class Event implements JsonSerializable {
|
||||
$this->id = $eventid;
|
||||
if (\Event::exists($eventid)) {
|
||||
$this->exists = true;
|
||||
$this->event = $database->get('events', ['machineid', 'eventid', 'techuid', 'date', 'privatenotes', 'publicnotes'], ['historyid' => $eventid]);
|
||||
$this->event = $database->get('events', ['machineid', 'eventname', 'eventid', 'techuid', 'date', 'privatenotes', 'publicnotes'], ['historyid' => $eventid]);
|
||||
}
|
||||
}
|
||||
|
||||
public static function create(string $machineid = "", string $date = "", int $event = 0, string $techuid = "", string $publicnotes = "", string $privatenotes = ""): Event {
|
||||
if ($machineid == "" || $date == "" || $event == 0) {
|
||||
public static function create(string $machineid = "", string $date = "", string $event = "", string $techuid = "", string $publicnotes = "", string $privatenotes = ""): Event {
|
||||
if ($machineid == "" || $date == "" || empty($event)) {
|
||||
return new Event("");
|
||||
} else {
|
||||
if (!Machine::exists($machineid)) {
|
||||
@ -30,13 +30,11 @@ class Event implements JsonSerializable {
|
||||
throw new Exception("Invalid date.");
|
||||
}
|
||||
$date = date("Y-m-d H:i:s", strtotime($date));
|
||||
if (!array_key_exists($event, \Event::getTypes())) {
|
||||
throw new Exception("Invalid event type.");
|
||||
}
|
||||
|
||||
$evt = new Event("");
|
||||
|
||||
$evt->setMachineID($machineid);
|
||||
$evt->setTypeID($event);
|
||||
$evt->setName($event);
|
||||
$evt->setDate($date);
|
||||
$evt->setTechUID($techuid);
|
||||
$evt->setPrivateNotes($privatenotes);
|
||||
@ -53,13 +51,8 @@ class Event implements JsonSerializable {
|
||||
}
|
||||
|
||||
public static function getTypes() {
|
||||
global $database;
|
||||
$types = $database->select("event_types", ["eventid (id)", "eventname (name)"]);
|
||||
$list = json_decode(file_get_contents(__DIR__ . '/events.json'), true);
|
||||
|
||||
$list = [];
|
||||
foreach ($types as $t) {
|
||||
$list[$t['id']] = $t['name'];
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
@ -70,7 +63,7 @@ class Event implements JsonSerializable {
|
||||
"info" => [
|
||||
"id" => $this->getID(),
|
||||
"machineid" => $this->getMachineID(),
|
||||
"type" => $this->getTypeID(),
|
||||
"name" => $this->getName(),
|
||||
"date" => $this->getDate(),
|
||||
"techuid" => $this->getTechUID(),
|
||||
"publicnotes" => $this->getPublicNotes(),
|
||||
@ -80,7 +73,7 @@ class Event implements JsonSerializable {
|
||||
"types" => $this->getTypes(),
|
||||
"inputtypes" => [
|
||||
"machineid" => "text",
|
||||
"type" => "number",
|
||||
"name" => "select",
|
||||
"date" => "datetime",
|
||||
"techuid" => "text",
|
||||
"privatenotes" => "textarea",
|
||||
@ -88,7 +81,7 @@ class Event implements JsonSerializable {
|
||||
],
|
||||
"labels" => [
|
||||
"machineid" => $Strings->get("Machine ID", false),
|
||||
"type" => $Strings->get("Type", false),
|
||||
"name" => $Strings->get("Event", false),
|
||||
"date" => $Strings->get("Date", false),
|
||||
"techuid" => $Strings->get("Technician", false),
|
||||
"privatenotes" => $Strings->get("Private Notes", false),
|
||||
@ -105,6 +98,17 @@ class Event implements JsonSerializable {
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
private static function getLegacyTypes() {
|
||||
global $database;
|
||||
$types = $database->select("event_types", ["eventid (id)", "eventname (name)"]);
|
||||
|
||||
$list = [];
|
||||
foreach ($types as $t) {
|
||||
$list[$t['id']] = $t['name'];
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
||||
public function save() {
|
||||
global $database;
|
||||
if ($this->exists) {
|
||||
@ -127,15 +131,13 @@ class Event implements JsonSerializable {
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getTypeID(): int {
|
||||
if (!empty($this->event["eventid"])) {
|
||||
return $this->event["eventid"] * 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
return $this->getTypes()[$this->getTypeID()] ?? "";
|
||||
if (!empty($this->event["eventname"])) {
|
||||
return $this->event["eventname"];
|
||||
} else if (!empty($this->event["eventid"])) {
|
||||
return self::getLegacyTypes()[$this->event["eventid"]];
|
||||
}
|
||||
return "Other";
|
||||
}
|
||||
|
||||
public function getDate(): string {
|
||||
@ -170,10 +172,8 @@ class Event implements JsonSerializable {
|
||||
$this->event["machineid"] = $id;
|
||||
}
|
||||
|
||||
public function setTypeID(int $id) {
|
||||
if (!empty($this->getTypes()[$id])) {
|
||||
$this->event["eventid"] = $id;
|
||||
}
|
||||
public function setName(string $name) {
|
||||
$this->event["eventname"] = $name;
|
||||
}
|
||||
|
||||
public function setTechUID($uid) {
|
||||
|
@ -241,12 +241,31 @@ INPUTG;
|
||||
$itemhtml .= <<<SELECT
|
||||
\n <select class="form-control$extraclass" name="$item[name]" aria-label="$strippedlabel" $required>
|
||||
SELECT;
|
||||
foreach ($item['options'] as $value => $label) {
|
||||
$selected = "";
|
||||
if (!empty($item['value']) && $value == $item['value']) {
|
||||
$selected = " selected";
|
||||
$ingroup = false;
|
||||
foreach ($item['options'] as $key => $val) {
|
||||
if (is_array($val)) {
|
||||
if ($ingroup) {
|
||||
$itemhtml .= "\n </optgroup>";
|
||||
}
|
||||
$ingroup = true;
|
||||
$itemhtml .= "\n <optgroup label=\"$key\">";
|
||||
foreach ($val as $k => $v) {
|
||||
$selected = "";
|
||||
if (!empty($item['value']) && $k == $item['value']) {
|
||||
$selected = " selected";
|
||||
}
|
||||
$itemhtml .= "\n <option value=\"$k\"$selected>$v</option>";
|
||||
}
|
||||
} else {
|
||||
$selected = "";
|
||||
if (!empty($item['value']) && $key == $item['value']) {
|
||||
$selected = " selected";
|
||||
}
|
||||
$itemhtml .= "\n <option value=\"$key\"$selected>$val</option>";
|
||||
}
|
||||
$itemhtml .= "\n <option value=\"$value\"$selected>$label</option>";
|
||||
}
|
||||
if ($ingroup) {
|
||||
$itemhtml .= "\n </optgroup>";
|
||||
}
|
||||
$itemhtml .= "\n </select>";
|
||||
break;
|
||||
@ -280,7 +299,7 @@ CHECKBOX;
|
||||
case "textarea":
|
||||
$val = htmlentities($item['value']);
|
||||
$itemhtml .= <<<TEXTAREA
|
||||
\n <textarea class="form-control" id="info" name="$item[name]" aria-label="$strippedlabel" minlength="$item[minlength]" maxlength="$item[maxlength]" $required>$val</textarea>
|
||||
\n <textarea class="form-control" $id name="$item[name]" aria-label="$strippedlabel" minlength="$item[minlength]" maxlength="$item[maxlength]" $required>$val</textarea>
|
||||
TEXTAREA;
|
||||
break;
|
||||
default:
|
||||
|
193
lib/Job.lib.php
Normal file
193
lib/Job.lib.php
Normal file
@ -0,0 +1,193 @@
|
||||
<?php
|
||||
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
class Job implements JsonSerializable {
|
||||
|
||||
private $jobid = -1;
|
||||
private $exists = false;
|
||||
private $machineid = "";
|
||||
private $jobname = "";
|
||||
private $clientid = "";
|
||||
private $startdate = 0;
|
||||
private $deadline = 0;
|
||||
private $finishdate = 0;
|
||||
private $info = "";
|
||||
private $notes = "";
|
||||
|
||||
public function __construct($jobid = false) {
|
||||
global $database;
|
||||
if ($jobid !== false) {
|
||||
$this->jobid = $jobid;
|
||||
if (Job::exists($jobid)) {
|
||||
$this->exists = true;
|
||||
$info = $database->get("jobs", ["[>]machines" => ["machineid"]], ["jobid", "jobs.machineid", "jobname", "clientid", "startdate", "deadline", "finishdate", "jobinfo", "jobnotes"], ["jobid" => $jobid]);
|
||||
$this->machineid = $info["machineid"];
|
||||
$this->jobname = $info["jobname"];
|
||||
$this->clientid = $info["clientid"];
|
||||
$this->startdate = strtotime($info["startdate"]);
|
||||
$this->deadline = strtotime($info["deadline"]);
|
||||
$this->finishdate = strtotime($info["finishdate"]);
|
||||
$this->info = $info["jobinfo"];
|
||||
$this->notes = $info["jobnotes"];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static function create(): Job {
|
||||
return new Job();
|
||||
}
|
||||
|
||||
public static function exists($id): bool {
|
||||
global $database;
|
||||
return $database->has('jobs', ['jobid' => $id]);
|
||||
}
|
||||
|
||||
public function toArray() {
|
||||
global $Strings;
|
||||
if ($this->exists) {
|
||||
return [
|
||||
"info" => [
|
||||
"jobid" => $this->getID(),
|
||||
"jobname" => $this->getName(),
|
||||
"machineid" => $this->getMachineID(),
|
||||
"startdate" => $this->getStartDate(),
|
||||
"deadline" => $this->getDeadline(),
|
||||
"finishdate" => $this->getFinishDate(),
|
||||
"jobinfo" => $this->getInfo(),
|
||||
"jobnotes" => $this->getNotes()
|
||||
],
|
||||
"formdata" => [
|
||||
"inputtypes" => [
|
||||
"jobname" => "text",
|
||||
"machineid" => "text",
|
||||
"startdate" => "datetime",
|
||||
"deadline" => "datetime",
|
||||
"finishdate" => "datetime",
|
||||
"jobinfo" => "textarea",
|
||||
"jobnotes" => "textarea"
|
||||
],
|
||||
"labels" => [
|
||||
"machineid" => $Strings->get("Machine ID", false),
|
||||
"jobname" => $Strings->get("Job Title", false),
|
||||
"startdate" => $Strings->get("Started", false),
|
||||
"deadline" => $Strings->get("Deadline", false),
|
||||
"finishdate" => $Strings->get("Finished", false),
|
||||
"jobinfo" => $Strings->get("Info", false),
|
||||
"jobnotes" => $Strings->get("Notes", false)
|
||||
],
|
||||
"icons" => []
|
||||
]
|
||||
];
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
public function jsonSerialize() {
|
||||
return $this->toArray();
|
||||
}
|
||||
|
||||
public function save() {
|
||||
global $database;
|
||||
$data = [
|
||||
"machineid" => $this->getMachineID(),
|
||||
"jobname" => $this->getName(),
|
||||
"startdate" => date("Y-m-d H:i:s", $this->getStartDate()),
|
||||
"deadline" => date("Y-m-d H:i:s", $this->getDeadline()),
|
||||
"finishdate" => date("Y-m-d H:i:s", $this->getFinishDate()),
|
||||
"jobinfo" => $this->getInfo(),
|
||||
"jobnotes" => $this->getNotes()
|
||||
];
|
||||
if ($this->exists) {
|
||||
$database->update("jobs", $data, ["jobid" => $this->jobid]);
|
||||
} else {
|
||||
$database->insert("jobs", $data);
|
||||
$this->jobid = $database->id();
|
||||
$this->exists = true;
|
||||
}
|
||||
}
|
||||
|
||||
public function getID(): int {
|
||||
return $this->jobid;
|
||||
}
|
||||
|
||||
public function getMachineID(): string {
|
||||
if (!empty($this->machineid)) {
|
||||
return $this->machineid;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getName(): string {
|
||||
if (!empty($this->jobname)) {
|
||||
return $this->jobname;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getStartDate(): int {
|
||||
if (!empty($this->startdate)) {
|
||||
return $this->startdate;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getDeadline(): int {
|
||||
if (!empty($this->deadline)) {
|
||||
return $this->deadline;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getFinishDate(): int {
|
||||
if (!empty($this->finishdate)) {
|
||||
return $this->finishdate;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public function getInfo(): string {
|
||||
if (!empty($this->info)) {
|
||||
return $this->info;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function getNotes(): string {
|
||||
if (!empty($this->notes)) {
|
||||
return $this->notes;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
public function setMachineID($id) {
|
||||
$this->machineid = $id;
|
||||
}
|
||||
|
||||
public function setName(string $name) {
|
||||
$this->jobname = $name;
|
||||
}
|
||||
|
||||
public function setStartDate($date) {
|
||||
$this->startdate = strtotime($date);
|
||||
}
|
||||
|
||||
public function setDeadline($date) {
|
||||
$this->deadline = strtotime($date);
|
||||
}
|
||||
|
||||
public function setFinishDate($date) {
|
||||
$this->finishdate = strtotime($date);
|
||||
}
|
||||
|
||||
public function setInfo(string $info) {
|
||||
$this->info = $info;
|
||||
}
|
||||
|
||||
public function setNotes(string $notes) {
|
||||
$this->notes = $notes;
|
||||
}
|
||||
|
||||
}
|
@ -171,7 +171,7 @@ class Machine implements JsonSerializable {
|
||||
$database->insert("machines", $data);
|
||||
$this->exists = true;
|
||||
// Insert event for machine creation
|
||||
Event::create($data["machineid"], date("Y-m-d H:i:s"), 99);
|
||||
Event::create($data["machineid"], date("Y-m-d H:i:s"), "Device ID Generated");
|
||||
}
|
||||
}
|
||||
|
||||
@ -323,7 +323,7 @@ class Machine implements JsonSerializable {
|
||||
return $this->machine["deleted"] == true;
|
||||
}
|
||||
|
||||
public function addEvent(string $date, int $event, string $techuid = "", string $publicnotes = "", string $privatenotes = "") {
|
||||
public function addEvent(string $date, string $event, string $techuid = "", string $publicnotes = "", string $privatenotes = "") {
|
||||
$evt = Event::create($this->machineid, $date, $event, $techuid, $publicnotes, $privatenotes);
|
||||
|
||||
$this->events[] = $evt;
|
||||
|
71
lib/TrackingCode.lib.php
Normal file
71
lib/TrackingCode.lib.php
Normal file
@ -0,0 +1,71 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2020 Netsyms Technologies.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
class TrackingCode {
|
||||
|
||||
public $code = "";
|
||||
public $type = "";
|
||||
public $containerid = "";
|
||||
public $trackingurl = "";
|
||||
public $exists = false;
|
||||
|
||||
public function __construct($code) {
|
||||
global $database;
|
||||
|
||||
if ($database->has("trackingcodes", ["code" => $code])) {
|
||||
$this->exists = true;
|
||||
$info = $database->get("trackingcodes", ["containerid", "code", "codetype"], ["code" => $code]);
|
||||
$this->code = $info["code"];
|
||||
$this->containerid = $info["containerid"];
|
||||
$this->type = $info["codetype"];
|
||||
} else {
|
||||
$this->exists = false;
|
||||
}
|
||||
}
|
||||
|
||||
public function getCarrier(): string {
|
||||
return TrackingCode::typeToCarrier($this->type);
|
||||
}
|
||||
|
||||
public function save() {
|
||||
global $database;
|
||||
|
||||
if (!$database->has("containers", ["containerid" => $this->containerid])) {
|
||||
throw new Exception("No container with ID $this->containerid exists.");
|
||||
return false;
|
||||
}
|
||||
if ($database->has("trackingcodes", ["code" => $code])) {
|
||||
$database->update("trackingcodes", [
|
||||
"codetype" => $this->type,
|
||||
"containerid" => $this->containerid
|
||||
], ["code" => $this->code]);
|
||||
} else {
|
||||
$database->insert("trackingcodes", [
|
||||
"code" => $this->code,
|
||||
"containerid" => $this->containerid,
|
||||
"codetype" => $this->type
|
||||
]);
|
||||
$this->exists = true;
|
||||
}
|
||||
}
|
||||
|
||||
public static function typeToCarrier($type) {
|
||||
switch (strtolower($type)) {
|
||||
case "usps":
|
||||
return "USPS";
|
||||
case "ups":
|
||||
return "UPS";
|
||||
case "fedex":
|
||||
return "FedEx";
|
||||
default:
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
49
lib/events.json
Normal file
49
lib/events.json
Normal file
@ -0,0 +1,49 @@
|
||||
{
|
||||
"Technical []": [
|
||||
"Diagnosed",
|
||||
"OS Installed",
|
||||
"Repaired",
|
||||
"Tested",
|
||||
"Upgraded",
|
||||
"Wiped"
|
||||
],
|
||||
"Delivered": [
|
||||
"Met Customer",
|
||||
"Left with Customer",
|
||||
"Installed",
|
||||
"Front Door/Porch",
|
||||
"Back/Side Door/Porch",
|
||||
"In Garage",
|
||||
"Left with Neighbor",
|
||||
"Left with Person at Address",
|
||||
"Secure Location",
|
||||
""
|
||||
],
|
||||
"Attempted": [
|
||||
"No answer at door",
|
||||
"Could not find destination",
|
||||
"Hazardous conditions",
|
||||
"Bad weather",
|
||||
"Unacceptable risk of loss",
|
||||
""
|
||||
],
|
||||
"Logistics []": [
|
||||
"Recieved from Customer",
|
||||
"Picked up",
|
||||
"In Transit",
|
||||
"Delayed",
|
||||
"Delivery Scheduled",
|
||||
"Received from shipping partner",
|
||||
"Transferred to shipping partner for delivery",
|
||||
"Accepted"
|
||||
],
|
||||
"Money []": [
|
||||
"Sold",
|
||||
"Refund Issued"
|
||||
],
|
||||
"Other []": [
|
||||
"Other",
|
||||
"Note",
|
||||
"Device ID Generated"
|
||||
]
|
||||
}
|
25
pages.php
25
pages.php
@ -38,6 +38,19 @@ define("PAGES", [
|
||||
"static/js/components.js"
|
||||
]
|
||||
],
|
||||
"jobs" => [
|
||||
"title" => "Jobs",
|
||||
"navbar" => true,
|
||||
"icon" => "fas fa-tasks",
|
||||
"styles" => [
|
||||
"static/css/datatables.min.css",
|
||||
"static/css/tables.css"
|
||||
],
|
||||
"scripts" => [
|
||||
"static/js/datatables.min.js",
|
||||
"static/js/jobs.js"
|
||||
]
|
||||
],
|
||||
"clients" => [
|
||||
"title" => "Clients",
|
||||
"navbar" => (empty($SETTINGS['apis']['invoiceninja']['token']) ? true : false),
|
||||
@ -77,7 +90,17 @@ define("PAGES", [
|
||||
"editclient" => [
|
||||
"title" => "Edit Client"
|
||||
],
|
||||
"editjob" => [
|
||||
"title" => "Edit Job",
|
||||
"styles" => [
|
||||
"static/css/easymde.min.css"
|
||||
],
|
||||
"scripts" => [
|
||||
"static/js/easymde.min.js",
|
||||
"static/js/editjob.js"
|
||||
],
|
||||
],
|
||||
"printlabel" => [
|
||||
"title" => "Print"
|
||||
],
|
||||
]);
|
||||
]);
|
||||
|
@ -28,14 +28,27 @@ $form->addHiddenInput("action", "addevent");
|
||||
$form->addHiddenInput("source", "viewmachine");
|
||||
$form->addHiddenInput("machine", htmlspecialchars($_GET['id']));
|
||||
|
||||
$events = $database->select("event_types", ['eventid', 'eventname']);
|
||||
$eventselect = ["" => ""];
|
||||
foreach ($events as $e) {
|
||||
// Skip automatic-only/internal events
|
||||
if ($e['eventid'] > 99) {
|
||||
continue;
|
||||
$eventtypes = Event::getTypes();
|
||||
$eventselect = [
|
||||
"" => ""
|
||||
];
|
||||
foreach ($eventtypes as $key => $val) {
|
||||
$optgroup = trim(str_replace("[]", "", $key));
|
||||
$valprepend = strpos($key, " []") !== false ? "" : trim($key);
|
||||
foreach ($val as $v) {
|
||||
if (empty($valprepend)) {
|
||||
$vpre = "";
|
||||
} else if (empty($v)) {
|
||||
$vpre = $valprepend;
|
||||
} else {
|
||||
$vpre = $valprepend . ": ";
|
||||
}
|
||||
if (empty($v)) {
|
||||
$eventselect[$optgroup][$vpre] = "[$vpre Other]";
|
||||
} else {
|
||||
$eventselect[$optgroup][$vpre . $v] = $v;
|
||||
}
|
||||
}
|
||||
$eventselect[$e['eventid']] = $e['eventname'];
|
||||
}
|
||||
|
||||
$form->addInput("event", "", "select", true, null, $eventselect, "Event", "fas fa-list");
|
||||
|
95
pages/containers.php
Normal file
95
pages/containers.php
Normal file
@ -0,0 +1,95 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2019 Netsyms Technologies.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
redirectIfNotLoggedIn();
|
||||
$user = new User($_SESSION['uid']);
|
||||
if (!$user->hasPermission("MACHINEMANAGER_VIEW")) {
|
||||
header("Location: ./app.php?msg=no_permission");
|
||||
die();
|
||||
}
|
||||
|
||||
$writeaccess = $user->hasPermission("MACHINEMANAGER_EDIT");
|
||||
|
||||
$containers = $database->select("containers", ["containerid", "barcode"]);
|
||||
|
||||
$addto = false;
|
||||
if (!empty($VARS["addto"]) && Machine::exists($VARS["addto"])) {
|
||||
$addto = $VARS["addto"];
|
||||
}
|
||||
?>
|
||||
|
||||
<?php if ($addto != false) { ?>
|
||||
<div class="alert alert-info" role="alert">
|
||||
Select a container to place machine #<?php echo htmlspecialchars($VARS["addto"]); ?> into.
|
||||
</div>
|
||||
<?php } else { ?>
|
||||
<div class="btn-group">
|
||||
<?php if ($writeaccess) { ?>
|
||||
<a href="app.php?page=addcontainer" class="btn btn-success"><i class="fas fa-plus"></i> <?php $Strings->get("Add Container"); ?></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<?php } ?>
|
||||
<table id="containertable" class="table table-bordered table-hover table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-priority="0"></th>
|
||||
<th data-priority="1"><?php $Strings->get('Actions'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-barcode hidden-sm"></i> <?php $Strings->get('Barcode'); ?></th>
|
||||
<th data-priority="3"><i class="fas fa-desktop hidden-sm"></i> <?php $Strings->get('Machines'); ?></th>
|
||||
<th data-priority="1"><i class="fas fa-memory hidden-sm"></i> <?php $Strings->get('Components'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-cubes hidden-sm"></i> <?php $Strings->get('Others'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-hashtag hidden-sm"></i> <?php $Strings->get('Total'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($containers as $c) {
|
||||
?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<?php
|
||||
if ($addto != false) {
|
||||
?>
|
||||
<a class="btn btn-success btn-sm" href="app.php?page=editcomponent&id=<?php echo $c['compid']; ?>&machine=<?php echo $attachto; ?>"><i class="fas fa-plus"></i> <?php $Strings->get("Attach"); ?></a>
|
||||
<?php
|
||||
} else if ($writeaccess) {
|
||||
?>
|
||||
<a class="btn btn-primary btn-sm" href="app.php?page=editcomponent&id=<?php echo $c['compid']; ?>"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><?php echo $c['compid']; ?></td>
|
||||
<td><?php
|
||||
if (!empty($c['machineid'])) {
|
||||
?>
|
||||
<a href="./app.php?page=viewmachine&id=<?php echo $c['machineid']; ?>"><?php echo $c['machineid']; ?></a>
|
||||
<?php
|
||||
}
|
||||
?></td>
|
||||
<td><?php echo $c['model'] ?? ""; ?></td>
|
||||
<td><?php echo $c['serial'] ?? ""; ?></td>
|
||||
<td><?php echo $c['capacity'] ?? ""; ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th data-priority="0"></th>
|
||||
<th data-priority="1"><?php $Strings->get('Actions'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-barcode hidden-sm"></i> <?php $Strings->get('Barcode'); ?></th>
|
||||
<th data-priority="3"><i class="fas fa-desktop hidden-sm"></i> <?php $Strings->get('Machines'); ?></th>
|
||||
<th data-priority="1"><i class="fas fa-memory hidden-sm"></i> <?php $Strings->get('Components'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-cubes hidden-sm"></i> <?php $Strings->get('Others'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-hashtag hidden-sm"></i> <?php $Strings->get('Total'); ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
47
pages/editjob.php
Normal file
47
pages/editjob.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
redirectIfNotLoggedIn();
|
||||
$user = new User($_SESSION['uid']);
|
||||
if (!$user->hasPermission("MACHINEMANAGER_EDIT")) {
|
||||
header("Location: ./app.php?msg=no_permission");
|
||||
die();
|
||||
}
|
||||
|
||||
$editing = false;
|
||||
|
||||
if (!empty($_GET['arg']) && Job::exists($_GET['arg'])) {
|
||||
$editing = true;
|
||||
$job = new Job($_GET['arg']);
|
||||
} else {
|
||||
$job = Job::create();
|
||||
}
|
||||
|
||||
if ($editing) {
|
||||
$form = new FormBuilder("Edit Job " . $job->getName(), "fas fa-tasks", "action.php", "POST");
|
||||
} else {
|
||||
$form = new FormBuilder("Add Job", "fas fa-tasks", "action.php", "POST");
|
||||
}
|
||||
|
||||
$form->setID("editjob");
|
||||
|
||||
$form->addHiddenInput("action", "editjob");
|
||||
$form->addHiddenInput("source", "viewjob");
|
||||
|
||||
if ($editing) {
|
||||
$form->addHiddenInput("jobid", $job->getID());
|
||||
}
|
||||
|
||||
$form->addInput("jobname", $job->getName(), "text", true, null, null, "Job Title", "fas fa-tasks", 8, 0, 200);
|
||||
$form->addInput("machineid", $job->getMachineID(), "text", false, null, null, "Machine ID", "fas fa-desktop", 4, 0, 200);
|
||||
$form->addInput("jobinfo", $job->getInfo(), "textarea", false, "jobinfo", null, "Info", "fas fa-comment-dots", 6, 0, 10000);
|
||||
$form->addInput("jobnotes", $job->getNotes(), "textarea", false, "jobnotes", null, "Notes", "far fa-comment-dots", 6, 0, 10000);
|
||||
|
||||
$form->addButton("Save", "fas fa-save", null, "submit", "savebtn");
|
||||
|
||||
$form->generate();
|
90
pages/jobs.php
Normal file
90
pages/jobs.php
Normal file
@ -0,0 +1,90 @@
|
||||
<?php
|
||||
/*
|
||||
* Copyright 2019 Netsyms Technologies.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
redirectIfNotLoggedIn();
|
||||
$user = new User($_SESSION['uid']);
|
||||
if (!$user->hasPermission("MACHINEMANAGER_VIEW")) {
|
||||
header("Location: ./app.php?msg=no_permission");
|
||||
die();
|
||||
}
|
||||
|
||||
$writeaccess = $user->hasPermission("MACHINEMANAGER_EDIT");
|
||||
|
||||
$jobs = $database->select("jobs", ["[>]machines" => ["machineid"]], ["jobid", "jobs.machineid", "jobname", "clientid", "startdate", "deadline", "finishdate"]);
|
||||
|
||||
$clients = Clients::getAll();
|
||||
?>
|
||||
|
||||
<div class="btn-group">
|
||||
<?php if ($writeaccess) { ?>
|
||||
<a href="app.php?page=editjob" class="btn btn-success"><i class="fas fa-plus"></i> <?php $Strings->get("Add Job"); ?></a>
|
||||
<?php } ?>
|
||||
</div>
|
||||
<table id="jobstable" class="table table-bordered table-hover table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-priority="0"></th>
|
||||
<th data-priority="1"><?php $Strings->get('Actions'); ?></th>
|
||||
<th data-priority="3"><i class="fas fa-tasks hidden-sm"></i> <?php $Strings->get('Job Title'); ?></th>
|
||||
<th data-priority="3"><i class="fas fa-desktop hidden-sm"></i> <?php $Strings->get('Machine'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-user hidden-sm"></i> <?php $Strings->get('Client'); ?></th>
|
||||
<th data-priority="4"><i class="fas fa-calendar-plus hidden-sm"></i> <?php $Strings->get('Started'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-calendar hidden-sm"></i> <?php $Strings->get('Deadline'); ?></th>
|
||||
<th data-priority="1"><i class="fas fa-calendar-check hidden-sm"></i> <?php $Strings->get('Finished'); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
foreach ($jobs as $j) {
|
||||
?>
|
||||
<tr>
|
||||
<td></td>
|
||||
<td>
|
||||
<?php
|
||||
if ($writeaccess) {
|
||||
?>
|
||||
<a class="btn btn-primary btn-sm" href="app.php?page=editjob&arg=<?php echo $j['jobid']; ?>"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</td>
|
||||
<td><a href="./app.php?page=viewjob&id=<?php echo $j['jobid']; ?>"><?php echo htmlspecialchars($j['jobname']); ?></a></td>
|
||||
<td>
|
||||
<?php if (!empty($j["machineid"])) { ?>
|
||||
<a href="./app.php?page=viewmachine&id=<?php echo $j['machineid']; ?>"><?php echo htmlspecialchars($j['machineid']); ?></a>
|
||||
<?php } ?>
|
||||
</td>
|
||||
<td><?php
|
||||
foreach ($clients as $c) {
|
||||
if ($c->getID() == $j['clientid']) {
|
||||
echo $c->getName();
|
||||
break;
|
||||
}
|
||||
}
|
||||
?></td>
|
||||
<td><?php echo $j['startdate'] ?? date($SETTINGS["datetime_format"], strtotime($j['startdate'])); ?></td>
|
||||
<td><?php echo $j['deadline'] ?? date($SETTINGS["datetime_format"], strtotime($j['deadline'])); ?></td>
|
||||
<td><?php echo $j['finishdate'] ?? date($SETTINGS["datetime_format"], strtotime($j['finishdate'])); ?></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th data-priority="0"></th>
|
||||
<th data-priority="1"><?php $Strings->get('Actions'); ?></th>
|
||||
<th data-priority="3"><i class="fas fa-tasks hidden-sm"></i> <?php $Strings->get('Job Title'); ?></th>
|
||||
<th data-priority="3"><i class="fas fa-desktop hidden-sm"></i> <?php $Strings->get('Machine'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-user hidden-sm"></i> <?php $Strings->get('Client'); ?></th>
|
||||
<th data-priority="4"><i class="fas fa-calendar-plus hidden-sm"></i> <?php $Strings->get('Started'); ?></th>
|
||||
<th data-priority="2"><i class="fas fa-calendar hidden-sm"></i> <?php $Strings->get('Deadline'); ?></th>
|
||||
<th data-priority="1"><i class="fas fa-calendar-check hidden-sm"></i> <?php $Strings->get('Finished'); ?></th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
</table>
|
@ -15,10 +15,9 @@ if (!$user->hasPermission("MACHINEMANAGER_VIEW")) {
|
||||
|
||||
$writeaccess = $user->hasPermission("MACHINEMANAGER_EDIT");
|
||||
|
||||
$machines = $database->query("SELECT machines.machineid, machines.clientid, machines.model, machines.os, machines.serial, events.date AS eventdate, events.eventid, event_types.eventname
|
||||
$machines = $database->query("SELECT machines.machineid, machines.clientid, machines.model, machines.os, machines.serial, events.date AS eventdate, events.eventname
|
||||
FROM machines
|
||||
LEFT OUTER JOIN events ON events.machineid = machines.machineid
|
||||
LEFT OUTER JOIN event_types ON event_types.eventid = events.eventid
|
||||
WHERE (date=(SELECT MAX(s2.date)
|
||||
FROM events s2
|
||||
WHERE machines.machineid = s2.machineid
|
||||
|
14
static/css/easymde.min.css
vendored
Normal file
14
static/css/easymde.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
14
static/js/easymde.min.js
vendored
Normal file
14
static/js/easymde.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
17
static/js/editjob.js
Normal file
17
static/js/editjob.js
Normal file
@ -0,0 +1,17 @@
|
||||
/*
|
||||
* Copyright 2020 Netsyms Technologies.
|
||||
* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
|
||||
var easyMDEinfo = new EasyMDE({
|
||||
element: document.getElementById("jobinfo"),
|
||||
forceSync: true
|
||||
});
|
||||
|
||||
var easyMDEnotes = new EasyMDE({
|
||||
element: document.getElementById("jobnotes"),
|
||||
forceSync: true
|
||||
});
|
30
static/js/jobs.js
Normal file
30
static/js/jobs.js
Normal file
@ -0,0 +1,30 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
$('#jobstable').DataTable({
|
||||
responsive: {
|
||||
details: {
|
||||
display: $.fn.dataTable.Responsive.display.modal({
|
||||
header: function (row) {
|
||||
var data = row.data();
|
||||
return "<i class=\"fas fa-tasks fa-fw\"></i> " + data[2];
|
||||
}
|
||||
}),
|
||||
renderer: $.fn.dataTable.Responsive.renderer.tableAll({
|
||||
tableClass: 'table'
|
||||
}),
|
||||
type: "column"
|
||||
}
|
||||
},
|
||||
columnDefs: [
|
||||
{
|
||||
targets: 0,
|
||||
className: 'control',
|
||||
orderable: false
|
||||
}
|
||||
],
|
||||
order: [
|
||||
[6, 'desc']
|
||||
]
|
||||
});
|
Loading…
x
Reference in New Issue
Block a user