_('Unknown'), 'precise' => _('Precise'), 'normal' => _('Normal'), 'rough' => _('Rough'), 'estimated' => _('Estimated') ); $opt_dimensions = array( 1 => _('1D'), 2 => _('2D'), 3 => _('3D') ); $opt_equipment = array(-1 => _('unassigned')); $sth = $pdo->prepare("SELECT eid, ename FROM equipment WHERE vid=? ORDER BY ename"); $sth->execute([$user->vid]); foreach ($sth->fetchAll() as $row) { $opt_equipment[$row['eid']] = $row['ename']; } // ========== ACTIONS START =================================================== switch ($submit = form_get_action()) { case NULL: break; case 'add': $action = ACT_ADD; break; case 'view': $action = ACT_VIEW; break; 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'); $p[':nval'] = gpc_get_int($_POST, 'nval'); // 1 to 3 dimensions $p[':val1'] = gpc_get_int($_POST, 'val1'); $p[':val2'] = NULL; $p[':val3'] = NULL; if ($p[':nval'] > 1) { $p[':val2'] = gpc_get_int($_POST, 'val2'); } if ($p[':nval'] > 2) { $p[':val3'] = gpc_get_int($_POST, 'val3'); } $p[':unit'] = gpc_get_int($_POST, 'unit'); $p[':accuracy'] = gpc_get_string($_POST, 'accuracy'); $p[':eid'] = gpc_get_int($_POST, 'eid'); if ($p[':eid'] == -1) { $p[':eid'] = NULL; } $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'); $p[':val2'] = NULL; $p[':val3'] = NULL; if ($p[':nval'] > 1) { $p[':val2'] = gpc_get_int($_POST, 'val2'); } if ($p[':nval'] > 2) { $p[':val3'] = gpc_get_int($_POST, 'val3'); } $p[':unit'] = gpc_get_int($_POST, 'unit'); $p[':accuracy'] = gpc_get_string($_POST, 'accuracy'); $p[':mdate'] = gpc_get_date($_POST, 'mdate'); $p[':note'] = gpc_get_string($_POST, 'note'); $p[':eid'] = gpc_get_int($_POST, 'eid'); if ($p[':eid'] == -1) { $p[':eid'] = NULL; } db_exec_update('measurement', $p, 'mid'); $action = ACT_VIEW; break; case 'delete': // Security token needed! if (gpc_get_string($_POST, 'token', 16) != $_SESSION['token']) { $g_error->Add(_('Delete prohibited, invalid security token!')); $action = ACT_VIEW; break; } $action = ACT_DEFAULT; break; default: $g_error->Add(sprintf(_('Unknown function!'), $submit)); $valid = FALSE; } // ========== ACTIONS END ===================================================== require 'header.php'; // ========== PAGE CONTENT ==================================================== if ($action == ACT_DEFAULT): // ========== VARIANT: default behavior ======================================= // load filter from db $flt = db_get_filter($user->id, 207); function format_vals($n, $v1, $v2, $v3) { if ($n == 1) { return $v1; } elseif ($n == 2) { return $v1 . 'x'. $v2; } else { return $v1 . 'x'. $v2 . 'x' . $v3; } } echo "
| ', _('Measurement'), " | "; echo '', _('Note'), " | "; echo '', _('Measured'), " | "; echo '', _('Unit'), " | "; echo '', _('Accuracy'), " | "; echo ""; echo " |
|---|---|---|---|---|---|
| ", $row['mname'], " | \n"; echo "", $row['note'], " | \n"; echo '', format_vals($row['nval'], $row['val1'], $row['val2'], $row['val3']), " | \n"; echo "", $opt_unit[$row['unit']], " | \n"; echo "", $opt_accuracy[$row['accuracy']], " | \n"; echo ""; // Action buttons form_action_buttons($g_scriptname, $row['mid']); echo " | \n"; echo "
| ', sprintf(_('%d records'), count($res)), ' | |||||
| ', _('Name')," | ", $measurement->mname, " |
|---|---|
| ', _('Unit')," | ", $opt_unit[$measurement->unit], " |
| ', _('Values')," | $measurement->nval |
| ', _('Value 1')," | $measurement->val1 |
| ', _('Value 2')," | $measurement->val2 |
| ', _('Value 3')," | $measurement->val3 |
| ', _('Accuracy')," | $measurement->accuracy |
| ', _('Date')," | $measurement->mdate |
| ', _('Note')," | $measurement->note |
', _('Unknown function call: Please report to system development!'), "
\n"; endif; // $action == ... // ========== END OF VARIANTS ================================================= include 'footer.php';