Webgui: filters and pagination

This commit is contained in:
2024-04-15 07:34:31 +02:00
parent 806cc407eb
commit 851f7e13a2
13 changed files with 248 additions and 246 deletions
+3 -18
View File
@@ -32,34 +32,19 @@ switch ($submit = form_get_action()) {
$p[':unit'] = gpc_get_int($_POST, 'unit');
$p[':storedate'] = gpc_get_string($_POST, 'storedate');
$p[':shelflife'] = gpc_get_string($_POST, 'shelflife');
$keys = array_keys($p);
$fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys));
$pnames = join(',', $keys);
$sth = $pdo->prepare("INSERT INTO provisions ($fields) VALUES ($pnames)");
try {
$sth->execute($p);
} catch (PDOexception $e) {
$g_error->Add('SQL-Error: '. $e->getMessage());
}
$id = $pdo->LastInsertId();
$id = db_exec_insert('provisions', $p);
$action = ACT_VIEW;
break;
case 'update':
$p[':provid'] = $id;
$p[':provname'] = gpc_get_string($_POST, 'provname');
$p[':number'] = gpc_get_int($_POST, 'number');
$p[':unit'] = gpc_get_int($_POST, 'unit');
$p[':storedate'] = gpc_get_string($_POST, 'storedate');
$p[':shelflife'] = gpc_get_string($_POST, 'shelflife');
$p[':sid'] = gpc_get_int($_POST, 'sid');
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
$sth = $pdo->prepare("UPDATE provisions SET $fields WHERE provid=:provid");
$p[':provid'] = $id;
try {
$sth->execute($p);
} catch (PDOexception $e) {
$g_error->Add('SQL-Error: '. $e->getMessage());
}
db_exec_update('provisions', $p, 'provid');
$action = ACT_VIEW;
break;