Allow components to be "floating" and not assigned to a machine
This commit is contained in:
parent
15d5834f78
commit
daae909068
@ -72,13 +72,15 @@ switch ($VARS['action']) {
|
|||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$component = new Component($VARS['id']);
|
||||||
|
|
||||||
|
if (!empty($VARS["machine"])) {
|
||||||
if (!Machine::exists($VARS['machine'])) {
|
if (!Machine::exists($VARS['machine'])) {
|
||||||
returnToSender("invalid_parameters");
|
returnToSender("invalid_parameters");
|
||||||
}
|
}
|
||||||
|
|
||||||
$component = new Component($VARS['id']);
|
|
||||||
|
|
||||||
$component->setMachineID($VARS['machine']);
|
$component->setMachineID($VARS['machine']);
|
||||||
|
}
|
||||||
|
|
||||||
$component->setSerial($VARS['serial']);
|
$component->setSerial($VARS['serial']);
|
||||||
$component->setTypeID($VARS['type']);
|
$component->setTypeID($VARS['type']);
|
||||||
if (!empty($VARS['date'])) {
|
if (!empty($VARS['date'])) {
|
||||||
|
BIN
database.mwb
BIN
database.mwb
Binary file not shown.
@ -8,5 +8,7 @@
|
|||||||
"Add Client": "Add Client",
|
"Add Client": "Add Client",
|
||||||
"Print": "Print",
|
"Print": "Print",
|
||||||
"Print Labels": "Print Labels",
|
"Print Labels": "Print Labels",
|
||||||
"Go to machine": "Go to machine"
|
"Go to machine": "Go to machine",
|
||||||
|
"Attach": "Attach",
|
||||||
|
"Attach Existing": "Attach Existing"
|
||||||
}
|
}
|
||||||
|
@ -2,5 +2,7 @@
|
|||||||
"Public Notes": "Public Notes",
|
"Public Notes": "Public Notes",
|
||||||
"Private Notes": "Private Notes",
|
"Private Notes": "Private Notes",
|
||||||
"Machine ID": "Machine ID",
|
"Machine ID": "Machine ID",
|
||||||
"Back": "Back"
|
"Back": "Back",
|
||||||
|
"Components": "Components"
|
||||||
|
|
||||||
}
|
}
|
13
pages.php
13
pages.php
@ -25,6 +25,19 @@ define("PAGES", [
|
|||||||
"static/js/machines.js"
|
"static/js/machines.js"
|
||||||
]
|
]
|
||||||
],
|
],
|
||||||
|
"components" => [
|
||||||
|
"title" => "Components",
|
||||||
|
"navbar" => true,
|
||||||
|
"icon" => "fas fa-memory",
|
||||||
|
"styles" => [
|
||||||
|
"static/css/datatables.min.css",
|
||||||
|
"static/css/tables.css"
|
||||||
|
],
|
||||||
|
"scripts" => [
|
||||||
|
"static/js/datatables.min.js",
|
||||||
|
"static/js/components.js"
|
||||||
|
]
|
||||||
|
],
|
||||||
"clients" => [
|
"clients" => [
|
||||||
"title" => "Clients",
|
"title" => "Clients",
|
||||||
"navbar" => (empty($SETTINGS['apis']['invoiceninja']['token']) ? true : false),
|
"navbar" => (empty($SETTINGS['apis']['invoiceninja']['token']) ? true : false),
|
||||||
|
90
pages/components.php
Normal file
90
pages/components.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");
|
||||||
|
|
||||||
|
$components = $database->select("components", ["compid", "serial", "machineid", "model", "manufacturer", "capacity"]);
|
||||||
|
|
||||||
|
$attachto = false;
|
||||||
|
if (!empty($VARS["attachto"]) && Machine::exists($VARS["attachto"])) {
|
||||||
|
$attachto = $VARS["attachto"];
|
||||||
|
}
|
||||||
|
?>
|
||||||
|
|
||||||
|
<div class="btn-group">
|
||||||
|
<?php if ($writeaccess) { ?>
|
||||||
|
<a href="app.php?page=editcomponent" class="btn btn-success"><i class="fas fa-plus"></i> <?php $Strings->get("Add Component"); ?></a>
|
||||||
|
<?php } ?>
|
||||||
|
</div>
|
||||||
|
<table id="componenttable" 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-memory hidden-sm"></i> <?php $Strings->get('ID'); ?></th>
|
||||||
|
<th data-priority="3"><i class="fas fa-desktop hidden-sm"></i> <?php $Strings->get('Machine ID'); ?></th>
|
||||||
|
<th data-priority="1"><i class="fas fa-barcode hidden-sm"></i> <?php $Strings->get('Model'); ?></th>
|
||||||
|
<th data-priority="2"><i class="fas fa-barcode hidden-sm"></i> <?php $Strings->get('Serial'); ?></th>
|
||||||
|
<th data-priority="2"><i class="fas fa-barcode hidden-sm"></i> <?php $Strings->get('Capacity'); ?></th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<?php
|
||||||
|
foreach ($components as $c) {
|
||||||
|
?>
|
||||||
|
<tr>
|
||||||
|
<td></td>
|
||||||
|
<td>
|
||||||
|
<?php
|
||||||
|
if ($attachto != 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><a href="./app.php?page=viewcomponent&id=<?php echo $c['compid']; ?>"><?php echo $c['compid']; ?></a></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="3"><i class="fas fa-desktop hidden-sm"></i> <?php $Strings->get('ID'); ?></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-hdd hidden-sm"></i> <?php $Strings->get('OS/Software'); ?></th>
|
||||||
|
<th data-priority="2"><i class="fas fa-hashtag hidden-sm"></i> <?php $Strings->get('Model'); ?></th>
|
||||||
|
<th data-priority="1"><i class="fas fa-calendar hidden-sm"></i> <?php $Strings->get('Last Event'); ?></th>
|
||||||
|
<th data-priority="3"><i class="fas fa-barcode hidden-sm"></i> <?php $Strings->get('Serial'); ?></th>
|
||||||
|
</tr>
|
||||||
|
</tfoot>
|
||||||
|
</table>
|
@ -24,15 +24,12 @@ if (!empty($VARS["arg"]) && Component::exists($VARS["arg"])) {
|
|||||||
$component = new Component($VARS["id"]);
|
$component = new Component($VARS["id"]);
|
||||||
$machine = new Machine($component->getMachineID());
|
$machine = new Machine($component->getMachineID());
|
||||||
} else {
|
} else {
|
||||||
if (!empty($VARS['machine']) && Machine::exists($VARS['machine'])) {
|
$component = Component::create();
|
||||||
$machine = new Machine($VARS['machine']);
|
$editing = false;
|
||||||
} else {
|
|
||||||
header("Location: ./app.php?msg=invalid_parameters");
|
|
||||||
die();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$editing = false;
|
if (!empty($VARS['machine']) && Machine::exists($VARS['machine'])) {
|
||||||
$component = Component::create();
|
$machine = new Machine($VARS['machine']);
|
||||||
$component->setMachineID($machine->getID());
|
$component->setMachineID($machine->getID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +42,6 @@ if ($editing) {
|
|||||||
$form->setID("editmachine");
|
$form->setID("editmachine");
|
||||||
|
|
||||||
$form->addHiddenInput("action", "editcomponent");
|
$form->addHiddenInput("action", "editcomponent");
|
||||||
$form->addHiddenInput("source", "viewmachine");
|
|
||||||
|
|
||||||
$types = [
|
$types = [
|
||||||
"" => ""
|
"" => ""
|
||||||
@ -60,7 +56,11 @@ if ($editing) {
|
|||||||
$form->addInput("id", $component->getID(), "text", true, null, null, "Component ID", "fas fa-memory", 4, 1, 20);
|
$form->addInput("id", $component->getID(), "text", true, null, null, "Component ID", "fas fa-memory", 4, 1, 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
$form->addHiddenInput("machine", $machine->getID());
|
if (!is_null($machine)) {
|
||||||
|
$form->addHiddenInput("source", "viewmachine");
|
||||||
|
} else {
|
||||||
|
$form->addHiddenInput("source", "components");
|
||||||
|
}
|
||||||
|
|
||||||
$date = date('Y-m-d');
|
$date = date('Y-m-d');
|
||||||
$time = date('H:i');
|
$time = date('H:i');
|
||||||
@ -68,6 +68,7 @@ if (!empty($component->getTestedDate())) {
|
|||||||
$date = date("Y-m-d", strtotime($component->getTestedDate()));
|
$date = date("Y-m-d", strtotime($component->getTestedDate()));
|
||||||
$time = date("H:i:s", strtotime($component->getTestedDate()));
|
$time = date("H:i:s", strtotime($component->getTestedDate()));
|
||||||
}
|
}
|
||||||
|
$form->addInput("machine", (is_null($machine) ? "" : $machine->getID()), "text", false, null, null, "Machine ID", "fas fa-desktop", 4, 0, 200);
|
||||||
$form->addInput("serial", $component->getSerial(), "text", false, null, null, "Serial", "fas fa-barcode", 4, 0, 200);
|
$form->addInput("serial", $component->getSerial(), "text", false, null, null, "Serial", "fas fa-barcode", 4, 0, 200);
|
||||||
$form->addInput("type", $component->getTypeID(), "select", false, null, $types, "Type", "fas fa-list");
|
$form->addInput("type", $component->getTypeID(), "select", false, null, $types, "Type", "fas fa-list");
|
||||||
$form->addInput("date", $date, "date", false, null, null, "Tested Date", "fas fa-calendar");
|
$form->addInput("date", $date, "date", false, null, null, "Tested Date", "fas fa-calendar");
|
||||||
@ -80,6 +81,10 @@ $form->addInput("privatenotes", $component->getPrivateNotes(), "textarea", false
|
|||||||
$form->addInput("publicnotes", $component->getPublicNotes(), "textarea", false, null, null, "Public Notes", "far fa-comment-dots", 6, 0, 10000);
|
$form->addInput("publicnotes", $component->getPublicNotes(), "textarea", false, null, null, "Public Notes", "far fa-comment-dots", 6, 0, 10000);
|
||||||
|
|
||||||
$form->addButton("Save", "fas fa-save", null, "submit", "savebtn");
|
$form->addButton("Save", "fas fa-save", null, "submit", "savebtn");
|
||||||
|
if (!is_null($machine)) {
|
||||||
$form->addButton("Back", "fas fa-arrow-left", "./app.php?page=viewmachine&id=" . $machine->getID(), "", null, null, "", "btn btn-info ml-2");
|
$form->addButton("Back", "fas fa-arrow-left", "./app.php?page=viewmachine&id=" . $machine->getID(), "", null, null, "", "btn btn-info ml-2");
|
||||||
|
} else {
|
||||||
|
$form->addButton("Back", "fas fa-arrow-left", "./app.php?page=components", "", null, null, "", "btn btn-info ml-2");
|
||||||
|
}
|
||||||
|
|
||||||
$form->generate();
|
$form->generate();
|
||||||
|
@ -33,7 +33,15 @@ $machine = new Machine($machineid);
|
|||||||
<div class="ml-auto">
|
<div class="ml-auto">
|
||||||
<a href="./app.php?page=editmachine&arg=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-primary btn-sm"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
|
<a href="./app.php?page=editmachine&arg=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-primary btn-sm"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
|
||||||
<a href="./app.php?page=addevent&id=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-success btn-sm"><i class="fas fa-history"></i> <?php $Strings->get("Add Event"); ?></a>
|
<a href="./app.php?page=addevent&id=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-success btn-sm"><i class="fas fa-history"></i> <?php $Strings->get("Add Event"); ?></a>
|
||||||
|
<div class="btn-group">
|
||||||
<a href="./app.php?page=editcomponent&machine=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-success btn-sm"><i class="fas fa-memory"></i> <?php $Strings->get("Add Component"); ?></a>
|
<a href="./app.php?page=editcomponent&machine=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-success btn-sm"><i class="fas fa-memory"></i> <?php $Strings->get("Add Component"); ?></a>
|
||||||
|
<button type="button" class="btn btn-success btn-sm dropdown-toggle dropdown-toggle-split" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
|
||||||
|
<span class="sr-only">Toggle Dropdown</span>
|
||||||
|
</button>
|
||||||
|
<div class="dropdown-menu">
|
||||||
|
<a class="dropdown-item" href="./app.php?page=components&attachto=<?php echo htmlspecialchars($machine->getID()); ?>"><?php $Strings->get("Attach Existing"); ?></a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<a href="./app.php?page=printlabel&id=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-info btn-sm"><i class="fas fa-print"></i> <?php $Strings->get("Print Labels"); ?></a>
|
<a href="./app.php?page=printlabel&id=<?php echo htmlspecialchars($machine->getID()); ?>" class="btn btn-info btn-sm"><i class="fas fa-print"></i> <?php $Strings->get("Print Labels"); ?></a>
|
||||||
<a href="./app.php?page=machines" class="btn btn-danger btn-sm"><i class="fas fa-arrow-left"></i> <?php $Strings->get("Back"); ?></a>
|
<a href="./app.php?page=machines" class="btn btn-danger btn-sm"><i class="fas fa-arrow-left"></i> <?php $Strings->get("Back"); ?></a>
|
||||||
</div>
|
</div>
|
||||||
|
34
static/js/components.js
Normal file
34
static/js/components.js
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
$('#componenttable').DataTable({
|
||||||
|
responsive: {
|
||||||
|
details: {
|
||||||
|
display: $.fn.dataTable.Responsive.display.modal({
|
||||||
|
header: function (row) {
|
||||||
|
var data = row.data();
|
||||||
|
return "<i class=\"fas fa-memory fa-fw\"></i> " + data[2];
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
renderer: $.fn.dataTable.Responsive.renderer.tableAll({
|
||||||
|
tableClass: 'table'
|
||||||
|
}),
|
||||||
|
type: "column"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
columnDefs: [
|
||||||
|
{
|
||||||
|
targets: 0,
|
||||||
|
className: 'control',
|
||||||
|
orderable: false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
targets: 1,
|
||||||
|
orderable: false
|
||||||
|
}
|
||||||
|
],
|
||||||
|
order: [
|
||||||
|
[6, 'desc']
|
||||||
|
]
|
||||||
|
});
|
32
update.sql
32
update.sql
@ -195,3 +195,35 @@ ADD COLUMN `deleted` TINYINT(1) NOT NULL DEFAULT 0 AFTER `publicnotes`;
|
|||||||
SET SQL_MODE=@OLD_SQL_MODE;
|
SET SQL_MODE=@OLD_SQL_MODE;
|
||||||
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
||||||
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
||||||
|
|
||||||
|
|
||||||
|
-- MySQL Workbench Synchronization
|
||||||
|
-- Generated: 2020-07-15 18:11
|
||||||
|
-- Model: New Model
|
||||||
|
-- Version: 1.0
|
||||||
|
-- Project: Name of the project
|
||||||
|
-- Author: Skylar Ittner
|
||||||
|
|
||||||
|
SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
|
||||||
|
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
|
||||||
|
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';
|
||||||
|
|
||||||
|
ALTER TABLE `machinemanager`.`components`
|
||||||
|
DROP FOREIGN KEY `fk_components_machines1`;
|
||||||
|
|
||||||
|
ALTER TABLE `machinemanager`.`components`
|
||||||
|
CHANGE COLUMN `machineid` `machineid` VARCHAR(20) NULL DEFAULT NULL ,
|
||||||
|
DROP PRIMARY KEY,
|
||||||
|
ADD PRIMARY KEY (`compid`);
|
||||||
|
|
||||||
|
ALTER TABLE `machinemanager`.`components`
|
||||||
|
ADD CONSTRAINT `fk_components_machines1`
|
||||||
|
FOREIGN KEY (`machineid`)
|
||||||
|
REFERENCES `machinemanager`.`machines` (`machineid`)
|
||||||
|
ON DELETE NO ACTION
|
||||||
|
ON UPDATE NO ACTION;
|
||||||
|
|
||||||
|
|
||||||
|
SET SQL_MODE=@OLD_SQL_MODE;
|
||||||
|
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
|
||||||
|
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user