Checks before removing objects

This commit is contained in:
2023-03-10 20:03:21 +01:00
parent 8c61638485
commit 02980bbad5
7 changed files with 36 additions and 2 deletions

View File

@@ -60,6 +60,13 @@ switch ($submit = form_get_action()) {
break;
case 'delete':
$sth = $dbh->prepare("SELECT COUNT(*) FROM asset WHERE assetclass_id=?");
$sth->execute([$id]);
if ($sth->fetchColumn() > 0) {
$g_warning->Add("Objektklasse kann nicht gelöscht werden, da noch zugeordnete Objekte vorhanden sind.");
$action = ACT_VIEW;
break;
}
$sth = $dbh->prepare("DELETE FROM assetclass WHERE assetclass_id=?");
try {
$sth->execute([$id]);