Settings page finished, filter gui improved

This commit is contained in:
2026-07-07 11:23:16 +02:00
parent 42df35f1a0
commit 2177834b39
12 changed files with 241 additions and 51 deletions
+15 -4
View File
@@ -15,6 +15,7 @@ $id = gpc_get_int($_REQUEST, 'id', 0);
$opt_mtype = db_load_enum('measurement', 'mtype', true, false);
$opt_unit = db_get_options(8);
// TODO use enum function
$opt_accuracy = array(
'unknown' => _('Unknown'),
'precise' => _('Precise'),
@@ -55,6 +56,7 @@ switch ($submit = form_get_action()) {
case 'insert':
$p[':mname'] = gpc_get_string($_POST, 'mname');
$p[':mtype'] = gpc_get_string($_POST, 'mtype');
$p[':note'] = gpc_get_string($_POST, 'note');
$p[':nval'] = gpc_get_int($_POST, 'nval'); // 1 to 3 dimensions
$p[':val1'] = gpc_get_int($_POST, 'val1');
@@ -79,6 +81,7 @@ switch ($submit = form_get_action()) {
case 'update':
$p[':mid'] = $id;
$p[':mname'] = gpc_get_string($_POST, 'mname');
$p[':mtype'] = gpc_get_string($_POST, 'mtype');
$p[':nval'] = gpc_get_int($_POST, 'nval'); // 1 to 3 dimensions
$p[':val1'] = gpc_get_int($_POST, 'val1');
$p[':val2'] = NULL;
@@ -171,6 +174,7 @@ $res = $sth->fetchAll();
echo '<table class="table table-striped">', "\n";
echo "<thead>\n";
echo "<tr>\n";
echo '<th>#</th>';
echo '<th>', _('Measurement'), "</th>";
echo '<th>', _('Note'), "</th>";
echo '<th class="text-end">', _('Measured'), "</th>";
@@ -179,16 +183,20 @@ echo '<th>', _('Accuracy'), "</th>";
echo "<th></th>";
echo "</tr>\n";
echo "</thead>\n";
$i = 0;
foreach ($res as $row) {
$i++;
echo "<tr>\n";
echo '<td>', $i;
echo '<a class="text-nowrap" title="', _('View'), '" href="', $g_scriptname, '?f=view&id=', $row['mid'], '"><i class="bi bi-eye ms-2"></i></a>';
echo "</td>\n";
echo "<td>", $row['mname'], "</td>\n";
echo "<td>", $row['note'], "</td>\n";
echo '<td class="text-end">', format_vals($row['nval'], $row['val1'], $row['val2'], $row['val3']), "</td>\n";
echo "<td>", $opt_unit[$row['unit']], "</td>\n";
echo "<td>", $opt_accuracy[$row['accuracy']], "</td>\n";
echo "<td>";
// Action buttons
form_action_buttons($g_scriptname, $row['mid']);
echo '<a class="text-nowrap" title="', _('Edit'), '" href="', $g_scriptname, '?f=edit&id=', $row['mid'], '"><i class="bi bi-pencil ms-2"></i></a>';
echo "</td>\n";
echo "</tr>\n";
}
@@ -216,6 +224,7 @@ echo '<h2>', _('Add measurement'), "</h2>\n";
<input type="text" class="form-control" id="note" name="note">
</div>
<?php
form_create_select('mtype', _('Type'), $opt_mtype);
form_create_select('nval', _('Dimensions'), $opt_dimensions);
?>
<div class="mb-3">
@@ -245,7 +254,7 @@ form_create_select('eid', _('Equipment'), $opt_equipment, $id);
elseif ($action == ACT_VIEW):
// ========== VARIANT: view single record =====================================
$sql = "SELECT mname, unit, nval, val1, val2, val3, accuracy, mdate, note, eid "
$sql = "SELECT mname, mtype, unit, nval, val1, val2, val3, accuracy, mdate, note, eid "
. "FROM measurement "
. "WHERE mid=?";
$sth = $pdo->prepare($sql);
@@ -256,6 +265,7 @@ echo '<h2>', _('Measurement'), "</h2>\n";
echo '<table class="table">', "\n";
echo '<tr><th style="width:20%">', _('Name'),"</th><td>", $measurement->mname, "</td></tr>\n";
echo '<tr><th>', _('Type'),"</th><td>", $opt_mtype[$measurement->mtype], "</td></tr>\n";
echo '<tr><th>', _('Unit'),"</th><td>", $opt_unit[$measurement->unit], "</td></tr>\n";
echo '<tr><th>', _('Values'),"</th><td>$measurement->nval</td></tr>\n";
echo '<tr><th>', _('Value 1'),"</th><td>$measurement->val1</td></tr>\n";
@@ -273,7 +283,7 @@ form_view_buttons($g_scriptname, $id);
elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record =====================================
$sql = "SELECT mname, nval, val1, val2, val3, unit, accuracy, note, eid "
$sql = "SELECT mname, mtype, nval, val1, val2, val3, unit, accuracy, note, eid "
. "FROM measurement "
. "WHERE mid=?";
$sth = $pdo->prepare($sql);
@@ -293,6 +303,7 @@ echo '<h2>', _('Edit measurement'), "</h2>\n";
<input type="text" class="form-control" id="note" name="note" value="<?=$measurement->note ?>">
</div>
<?php
form_create_select('mtype', _('Type'), $opt_mtype, $measurement->mtype);
form_create_select('nval', _('Dimensions'), $opt_dimensions, $measurement->nval);
?>
<div class="mb-3">