Webgui code improvements for dropdown handling
This commit is contained in:
+10
-3
@@ -25,7 +25,8 @@ $pagetitle = _('Measurements');
|
||||
|
||||
$id = gpc_get_int($_REQUEST, 'id', 0);
|
||||
|
||||
$opt_unit = db_get_options(8);
|
||||
$opt_unit = db_get_options(DD_UNIT);
|
||||
$opt_category = db_get_options(DD_MEASUREMENT_CATEGORY);
|
||||
$opt_accuracy = db_load_enum('measurement', 'accuracy', true, true);
|
||||
$opt_dimensions = array(
|
||||
1 => _('1D'),
|
||||
@@ -102,6 +103,10 @@ switch ($submit = form_get_action()) {
|
||||
$p[':unit'] = gpc_get_int($_POST, 'unit');
|
||||
$p[':accuracy'] = gpc_get_string($_POST, 'accuracy');
|
||||
$p[':mdate'] = gpc_get_date($_POST, 'mdate');
|
||||
$p[':mcat'] = gpc_get_int($_POST, 'mcat');
|
||||
if ($p[':mcat'] == -1) {
|
||||
$p[':mcat'] = NULL;
|
||||
}
|
||||
$p[':note'] = gpc_get_string($_POST, 'note');
|
||||
$p[':eid'] = gpc_get_int($_POST, 'eid');
|
||||
if ($p[':eid'] == -1) {
|
||||
@@ -291,7 +296,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, unit, nval, val1, val2, val3, accuracy, mdate, mcat, note, eid "
|
||||
. "FROM measurement "
|
||||
. "WHERE mid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -310,6 +315,7 @@ echo '<tr><th>', _('Value 3'), '</th><td>', $measurement->val3, "</td></tr>\n";
|
||||
echo '<tr><th>', _('Accuracy'), '</th><td>', get_enum($measurement->accuracy), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Date'), '</th><td>', format_date($measurement->mdate), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Note'), '</th><td>', h($measurement->note), "</td></tr>\n";
|
||||
echo '<tr><th>', _('Category'),"</th><td>", $opt_category[$measurement->mcat] ?? 'n/a', "</td></tr>\n";
|
||||
echo '<tr><th>', _('Equipment'), '</th><td>', $opt_equipment[$measurement->eid], "</td></tr>\n";
|
||||
echo "</table>\n";
|
||||
|
||||
@@ -319,7 +325,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, nval, val1, val2, val3, unit, accuracy, note, eid, mcat "
|
||||
. "FROM measurement "
|
||||
. "WHERE mid=?";
|
||||
$sth = $pdo->prepare($sql);
|
||||
@@ -356,6 +362,7 @@ form_create_select('nval', _('Dimensions'), $opt_dimensions, $measurement->nval)
|
||||
<?php
|
||||
form_create_select('unit', _('Unit'), $opt_unit, $measurement->unit);
|
||||
form_create_select('accuracy', _('Accuracy'), $opt_accuracy, $measurement->accuracy);
|
||||
form_create_select('mcat', _('Category'), $g_opt_none + $opt_category, $measurement->mcat);
|
||||
form_create_select('eid', _('Equipment'), $opt_equipment, $measurement->eid);
|
||||
|
||||
form_edit_buttons($g_scriptname, $id);
|
||||
|
||||
Reference in New Issue
Block a user