Add unlink component
This commit is contained in:
parent
580d236148
commit
5b05cda1d0
31
action.php
31
action.php
@ -105,6 +105,37 @@ switch ($VARS['action']) {
|
|||||||
returnToSender("component_saved");
|
returnToSender("component_saved");
|
||||||
}
|
}
|
||||||
returnToSender("component_saved", $component->getMachineID());
|
returnToSender("component_saved", $component->getMachineID());
|
||||||
|
case "unlinkcomponent":
|
||||||
|
$user = new User($_SESSION['uid']);
|
||||||
|
if (!$user->hasPermission("MACHINEMANAGER_EDIT")) {
|
||||||
|
returnToSender("no_permission");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
$component = new Component($VARS['id']);
|
||||||
|
|
||||||
|
$component->setMachineID(null);
|
||||||
|
|
||||||
|
$component->save();
|
||||||
|
|
||||||
|
if (!empty($VARS["machine"])) {
|
||||||
|
if (Machine::exists($VARS['machine'])) {
|
||||||
|
returnToSender("component_unlinked", $VARS["machine"]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
returnToSender("component_unlinked");
|
||||||
|
case "deletecomponent":
|
||||||
|
$user = new User($_SESSION['uid']);
|
||||||
|
if (!$user->hasPermission("MACHINEMANAGER_EDIT")) {
|
||||||
|
returnToSender("no_permission");
|
||||||
|
die();
|
||||||
|
}
|
||||||
|
|
||||||
|
$component = new Component($VARS['id']);
|
||||||
|
|
||||||
|
$component->delete();
|
||||||
|
|
||||||
|
returnToSender("component_deleted");
|
||||||
case "addevent":
|
case "addevent":
|
||||||
$user = new User($_SESSION['uid']);
|
$user = new User($_SESSION['uid']);
|
||||||
if (!$user->hasPermission("MACHINEMANAGER_EDIT")) {
|
if (!$user->hasPermission("MACHINEMANAGER_EDIT")) {
|
||||||
|
@ -10,5 +10,6 @@
|
|||||||
"Print Labels": "Print Labels",
|
"Print Labels": "Print Labels",
|
||||||
"Go to machine": "Go to machine",
|
"Go to machine": "Go to machine",
|
||||||
"Attach": "Attach",
|
"Attach": "Attach",
|
||||||
"Attach Existing": "Attach Existing"
|
"Attach Existing": "Attach Existing",
|
||||||
|
"Detach": "Detach"
|
||||||
}
|
}
|
||||||
|
@ -5,5 +5,7 @@
|
|||||||
"Client saved!": "Client saved!",
|
"Client saved!": "Client saved!",
|
||||||
"Client must be edited in Invoice Ninja.": "Client must be edited in Invoice Ninja.",
|
"Client must be edited in Invoice Ninja.": "Client must be edited in Invoice Ninja.",
|
||||||
"That ID does not exist in the system.": "That ID does not exist in the system.",
|
"That ID does not exist in the system.": "That ID does not exist in the system.",
|
||||||
"Machine deleted.": "Machine deleted."
|
"Machine deleted.": "Machine deleted.",
|
||||||
|
"Component unlinked.": "Component unlinked.",
|
||||||
|
"Component deleted.": "Component deleted."
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,14 @@ define("MESSAGES", [
|
|||||||
"string" => "Machine deleted.",
|
"string" => "Machine deleted.",
|
||||||
"type" => "success"
|
"type" => "success"
|
||||||
],
|
],
|
||||||
|
"component_unlinked" => [
|
||||||
|
"string" => "Component unlinked.",
|
||||||
|
"type" => "success"
|
||||||
|
],
|
||||||
|
"component_deleted" => [
|
||||||
|
"string" => "Component deleted.",
|
||||||
|
"type" => "success"
|
||||||
|
],
|
||||||
"404_error" => [
|
"404_error" => [
|
||||||
"string" => "page not found",
|
"string" => "page not found",
|
||||||
"type" => "info"
|
"type" => "info"
|
||||||
|
@ -105,6 +105,11 @@ class Component implements JsonSerializable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function delete() {
|
||||||
|
global $database;
|
||||||
|
$database->delete("components", ["compid" => $this->componentid]);
|
||||||
|
}
|
||||||
|
|
||||||
public function getID(): string {
|
public function getID(): string {
|
||||||
return $this->componentid . "";
|
return $this->componentid . "";
|
||||||
}
|
}
|
||||||
|
@ -190,6 +190,7 @@ $machine = new Machine($machineid);
|
|||||||
?>
|
?>
|
||||||
<div class="list-group-item">
|
<div class="list-group-item">
|
||||||
<div class="float-right">
|
<div class="float-right">
|
||||||
|
<a class="btn btn-danger btn-sm" href="./action.php?action=unlinkcomponent&source=viewmachine&id=<?php echo $c->getID(); ?>&machine=<?php echo $machine->getID(); ?>"><i class="fas fa-unlink"></i> <?php $Strings->get("Detach"); ?></a>
|
||||||
<a class="btn btn-primary btn-sm" href="./app.php?page=editcomponent&id=<?php echo $c->getID(); ?>"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
|
<a class="btn btn-primary btn-sm" href="./app.php?page=editcomponent&id=<?php echo $c->getID(); ?>"><i class="fas fa-edit"></i> <?php $Strings->get("Edit"); ?></a>
|
||||||
</div>
|
</div>
|
||||||
<b><?php echo $c->getTypeName(); ?></b><br />
|
<b><?php echo $c->getTypeName(); ?></b><br />
|
||||||
|
Loading…
x
Reference in New Issue
Block a user