prepare($sql); $sth->bindValue(':vid', $user->vid, PDO::PARAM_INT); $sth->bindValue(':sname', $sname, PDO::PARAM_STR); $sth->bindValue(':stype', $stype, PDO::PARAM_INT); $sth->execute(); $id = $pdo->lastInsertId(); $action = ACT_VIEW; break; case 'update': $sname = gpc_get_string($_POST, 'sname'); $x = gpc_get_int($_POST, 'x'); $y = gpc_get_int($_POST, 'y'); $z = gpc_get_int($_POST, 'z'); $remarks = gpc_get_string($_POST, 'remarks', 150); $sql = "UPDATE storage " . "SET sname=:sname," . " x=:x, y=:y, z=:z," . " remarks=:remarks " . "WHERE sid=:sid"; $sth = $pdo->prepare($sql); $sth->bindValue(':sid', $id, PDO::PARAM_INT); $sth->bindValue(':sname', $sname, PDO::PARAM_STR); $sth->bindValue(':x', $x, PDO::PARAM_INT); $sth->bindValue(':y', $y, PDO::PARAM_INT); $sth->bindValue(':z', $z, PDO::PARAM_INT); $sth->bindValue(':remarks', $remarks, PDO::PARAM_STR); $sth->execute(); $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 boxtype='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 ======================================= echo '
| " . _('Name') . " | "; echo "" . _('Remarks') . " | "; echo ""; echo " |
|---|---|---|
| ". $row['sname'] ." | \n"; echo "". $row['remarks'] ." | \n"; form_action_buttons($g_scriptname, $row['sid']); echo "|
| ', sprintf(_('%d records'), count($res)), ' | ||
| " . _('Label') . " | "; echo "" . _('Color') . " | "; echo "" . _('Content') . " | "; echo ""; echo " |
|---|---|---|---|
| ". $row['label'] ." | \n"; echo '', format_color($row['color']), " | \n"; echo "". $row['content'] ." | \n"; form_action_buttons('box.php', $row['boxid']); echo "|
| ', sprintf(_('%d records'), count($res)), ' | |||
| ', _('Typ')," | ", $stype[$storage->stype], " |
|---|---|
| ', _('Capacity')," | ", $storage->capacity, ' ', $storage->capaunit, " |
| ', _('Location (x, y, z)')," | (", $storage->x ?? '?', ', ', $storage->y ?? '?', ', ', $storage->z, ") |
| ', _('Remarks')," | ", $storage->remarks, " |
', _('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';