Webgui: filters and pagination
This commit is contained in:
+3
-18
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user