Webgui: filters and pagination
This commit is contained in:
+3
-18
@@ -36,33 +36,18 @@ switch ($submit = form_get_action()) {
|
||||
$p[':sid'] = gpc_get_int($_POST, 'sid');
|
||||
$p[':content'] = gpc_get_string($_POST, 'content');
|
||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks');
|
||||
$keys = array_keys($p);
|
||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys));
|
||||
$pnames = join(',', $keys);
|
||||
$sth = $pdo->prepare("INSERT INTO box ($fields) VALUES ($pnames)");
|
||||
try {
|
||||
$sth->execute($p);
|
||||
} catch (PDOexception $e) {
|
||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
||||
}
|
||||
$id = $pdo->LastInsertId();
|
||||
$id = db_exec_insert('box', $p);
|
||||
$action = ACT_VIEW;
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$p[':boxid'] = $id;
|
||||
$p[':label'] = gpc_get_string($_POST, 'label');
|
||||
$p[':content'] = gpc_get_string($_POST, 'content');
|
||||
$p[':color'] = gpc_get_color($_POST, 'color');
|
||||
$p[':weight'] = min(gpc_get_float($_POST, 'weight'), 99.99);
|
||||
$p[':remarks'] = gpc_get_string($_POST, 'remarks', 150);
|
||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
|
||||
$sth = $pdo->prepare("UPDATE box SET $fields WHERE boxid=:boxid");
|
||||
$p[':boxid'] = $id;
|
||||
try {
|
||||
$sth->execute($p);
|
||||
} catch (PDOexception $e) {
|
||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
||||
}
|
||||
db_exec_update('box', $p, 'boxid');
|
||||
$action = ACT_VIEW;
|
||||
break;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user