More webgui work. Filters e.g.
This commit is contained in:
+30
-18
@@ -42,6 +42,14 @@ switch ($submit = form_get_action()) {
|
||||
case 'edit': $action = ACT_EDIT; break;
|
||||
case 'del': $action = ACT_DELETE; break;
|
||||
|
||||
case 'filter':
|
||||
$flt = array();
|
||||
$flt['precision'] = gpc_get_string($_POST, 'flt_precision');
|
||||
$flt['txt'] = gpc_get_string($_POST, 'flt_txt');
|
||||
db_save_filter($flt, 207);
|
||||
$action = ACT_DEFAULT;
|
||||
break;
|
||||
|
||||
case 'insert':
|
||||
$p[':mname'] = gpc_get_string($_POST, 'mname');
|
||||
$p[':note'] = gpc_get_string($_POST, 'note');
|
||||
@@ -61,20 +69,12 @@ switch ($submit = form_get_action()) {
|
||||
if ($p[':eid'] == -1) {
|
||||
$p[':eid'] = NULL;
|
||||
}
|
||||
$keys = array_keys($p);
|
||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':'); }, $keys));
|
||||
$pnames = join(',', $keys);
|
||||
$sth = $pdo->prepare("INSERT INTO measurement ($fields) VALUES ($pnames)");
|
||||
try {
|
||||
$sth->execute($p);
|
||||
} catch (PDOexception $e) {
|
||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
||||
}
|
||||
$id = $pdo->LastInsertId();
|
||||
$id = db_exec_insert('measurement', $p);
|
||||
$action = ACT_VIEW;
|
||||
break;
|
||||
|
||||
case 'update':
|
||||
$p[':mid'] = $id;
|
||||
$p[':mname'] = gpc_get_string($_POST, 'mname');
|
||||
$p[':nval'] = gpc_get_int($_POST, 'nval'); // 1 to 3 dimensions
|
||||
$p[':val1'] = gpc_get_int($_POST, 'val1');
|
||||
@@ -94,14 +94,7 @@ switch ($submit = form_get_action()) {
|
||||
if ($p[':eid'] == -1) {
|
||||
$p[':eid'] = NULL;
|
||||
}
|
||||
$fields = join(',', array_map(function($s) { return ltrim($s, ':') . '=' . $s; }, array_keys($p)));
|
||||
$sth = $pdo->prepare("UPDATE measurement SET $fields WHERE mid=:mid");
|
||||
$p[':mid'] = $id;
|
||||
try {
|
||||
$sth->execute($p);
|
||||
} catch (PDOexception $e) {
|
||||
$g_error->Add('SQL-Error: '. $e->getMessage());
|
||||
}
|
||||
db_exec_update('measurement', $p, 'mid');
|
||||
$action = ACT_VIEW;
|
||||
break;
|
||||
|
||||
@@ -143,6 +136,25 @@ function format_vals($n, $v1, $v2, $v3) {
|
||||
|
||||
echo "<h1>$pagetitle</h1>\n";
|
||||
|
||||
// Filter
|
||||
$opt_special = array(
|
||||
-2 => _('― all ―'),
|
||||
-1 => _('― none ―')
|
||||
);
|
||||
?>
|
||||
<form method="post" action="<?=$g_scriptname?>">
|
||||
<div id="filter" class="card">
|
||||
<div class="card-header">Filter</div>
|
||||
<div class="card-body">
|
||||
|
||||
<label for="flt_txt">Text</label>
|
||||
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt?>">
|
||||
<button name="submit[filter]" class="btn btn-sm btn-primary" title="<?=_('Apply')?>"><?=_('Go')?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
$sql = "SELECT mid, mname, nval, val1, val2, val3, unit, accuracy, mdate, note, eid "
|
||||
. "FROM measurement "
|
||||
. "ORDER BY mname";
|
||||
|
||||
Reference in New Issue
Block a user