vid; $p[':sname'] = gpc_get_string($_POST, 'sname'); $p[':stype'] = gpc_get_int($_POST, 'stype'); $id = db_exec_insert('storage', $p); $action = ACT_VIEW; break; case 'update': $p[':sid'] = $id; $p[':sname'] = gpc_get_string($_POST, 'sname'); $p[':x'] = gpc_get_int($_POST, 'x'); $p[':y'] = gpc_get_int($_POST, 'y'); $p[':z'] = gpc_get_int($_POST, 'z'); $p[':wx'] = gpc_get_int($_POST, 'wx'); $p[':wy'] = gpc_get_int($_POST, 'wy'); $p[':wz'] = gpc_get_int($_POST, 'wz'); $p[':remarks'] = gpc_get_string($_POST, 'remarks', 150); db_exec_update('storage', $p, 'sid'); $action = ACT_VIEW; break; case 'delete': // Security token needed! if (gpc_get_string($_POST, 'token', 16) != $_SESSION['token']) { $g_error->Add(_('Delete prohibited, invalid security token!')); $action = ACT_VIEW; break; } unset($_SESSION['token']); // check if storage is empty // - no assigned boxes $sth = $pdo->prepare("SELECT COUNT(*) FROM box WHERE sid=?"); $sth->execute([$id]); if ($sth->fetchColumn() > 0) { $g_error->Add(_('Delete failed, assigned boxes detected!')); $action = ACT_VIEW; break; } // - no assigned equipment $sth = $pdo->prepare("SELECT COUNT(*) FROM inventory WHERE conttype='storage' AND sid=?"); $sth->execute([$id]); if ($sth->fetchColumn() > 0) { $g_error->Add(_('Delete failed, assigned equipment detected!')); $action = ACT_VIEW; break; } $sth = $pdo->prepare("DELETE FROM storage WHERE sid=?"); $sth->execute([$id]); $g_message->Add(sprintf(_('Deleted storage no. %d'), $id)); $action = ACT_DEFAULT; break; default: $g_error->Add(sprintf(_("Unknown function '%s'!"), $submit)); $valid = FALSE; } // ========== ACTIONS END ===================================================== require 'header.php'; // ========== PAGE CONTENT ==================================================== if ($action == ACT_DEFAULT): // ========== VARIANT: default behavior ======================================= page_caption_search($pagetitle); // Storage // stype from dropdown $sql = "SELECT sid, sname, x, y, z, angle, remarks " . "FROM storage " . "WHERE vid=? " . "ORDER BY sid"; $sth = $pdo->prepare($sql); $sth->execute([$user->vid]); $res = $sth->fetchAll(); echo '
| ', _('Typ')," | ", $stype[$storage->stype], " |
|---|---|
| ', _('Capacity')," | ", $storage->capacity, ' ', $storage->capaunit, " |
| ', _('Location (x, y, z)')," | (", $storage->x, ', ', $storage->y, ', ', $storage->z, ") |
| ', _('Width (wx, wy, wz)')," | (", $storage->wx, ', ', $storage->wy, ', ', $storage->wz, ") |
| ', _('Angle')," | ", $storage->angle, "° |
| ', _('Color')," | ", $storage->color, " |
| ', _('Remarks')," | ", $storage->remarks, " |
| ', $row['label'], " | "; echo '', format_color($row['color']), " | "; echo ''; echo " |
', _('No boxes contained'), "
\n"; } echo '| ", $row['provname'], " | "; echo "", $row['number'], ' ', $opt_unit[$row['unit']], " | "; echo "", $row['storedate'], ' - ', $row['shelflife'], " | "; echo "
', _('No provisions contained'), "
\n"; } elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== echo '', sprintf(_('Record no. %d'), $id), "
\n"; echo 'Name: ', $storage->sname, "
"; echo 'Remarks: ', $storage->remarks, "
"; echo '', _('Deleting a storage is final. There is no way back. Only delete if you are absolute sure.'), "
\n"; form_delete_buttons($g_scriptname, $id, $_SESSION['token']); else: // ========== ERROR UNKNOWN VARIANT =========================================== echo '', _('Unknown function call: Please report to system development!'), "
\n"; endif; // $action == ... // ========== END OF VARIANTS ================================================= include 'footer.php';