diff --git a/db/mariadb.sql b/db/mariadb.sql
index 88b3acf..4e475bd 100644
--- a/db/mariadb.sql
+++ b/db/mariadb.sql
@@ -296,7 +296,7 @@ CREATE TABLE cable (
ON DELETE RESTRICT
) ENGINE=InnoDB;
-CREATE table fuse (
+CREATE TABLE fuse (
fuseid smallint(6) UNSIGNED NOT NULL AUTO_INCREMENT,
vid smallint(6) NOT NULL DEFAULT 1,
fnumber smallint(6) NOT NULL,
@@ -306,6 +306,7 @@ CREATE table fuse (
eid smallint(6) UNSIGNED DEFAULT NULL,
location tinyint(3) DEFAULT 0, -- from dropdown id 10
description varchar(60) DEFAULT NULL,
+ color char(6) DEFAULT NULL,
remarks varchar(150) DEFAULT NULL,
PRIMARY KEY (fuseid),
UNIQUE INDEX ix_fusenumber (vid, fnumber),
diff --git a/webgui/box.php b/webgui/box.php
index a173481..7ba98e4 100644
--- a/webgui/box.php
+++ b/webgui/box.php
@@ -16,6 +16,7 @@ There can be a difference because not all items have a weight entered
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
$pagetitle = _('Boxes');
@@ -118,7 +119,7 @@ foreach ($res as $row) {
echo '
=_('Current, Ampere')?>
@@ -218,7 +230,7 @@ echo "\n";
elseif ($action == ACT_VIEW):
// ========== VARIANT: view single record =====================================
-$sql = "SELECT fnumber, ftype, current, cableid, eid, location, description, remarks "
+$sql = "SELECT fnumber, ftype, current, cableid, eid, location, description, color, remarks "
. "FROM fuse "
. "WHERE vid=? AND fuseid=?";
$sth = $pdo->prepare($sql);
@@ -232,6 +244,7 @@ echo '
', _('Fuse')," F", $fuse->fnumber, " ', _('Description')," ", $fuse->description, " \n";
echo '
', _('Type')," ", $opt_ftype[$fuse->ftype], " \n";
echo '
', _('Current')," ", $fuse->current, "A \n";
+echo '
', _('Color')," ", format_color($fuse->color), " \n";
echo '
', _('Location')," ", $opt_location[$fuse->location], " \n";
echo '
', _('Cable')," ", $fuse->cableid, " \n";
echo '
', _('Equipment')," ", $fuse->eid, " \n";
@@ -246,7 +259,7 @@ elseif ($action == ACT_EDIT):
$opt_cable = db_get_opt_cable($user->vid);
$opt_equipment = db_get_opt_equip($user->vid);
-$sql = "SELECT fnumber, ftype, current, cableid, eid, location, description, remarks "
+$sql = "SELECT fnumber, ftype, current, cableid, eid, location, description, color, remarks "
. "FROM fuse "
. "WHERE fuseid=?";
$sth = $pdo->prepare($sql);
@@ -259,8 +272,11 @@ echo '
', _('Edit fuse'), " \n";
=_('Fuse number')?>
-
+
+ftype);
+?>
=_('Description')?>
@@ -269,6 +285,10 @@ echo '
', _('Edit fuse'), " \n";
=_('Current')?>
+
+ =_('Color')?>
+
+
location);
form_create_select('cableid', _('Cable'), $g_opt_none + $opt_cable, $fuse->cableid);
diff --git a/webgui/globals.inc b/webgui/globals.inc
index 6eb8656..29c1bd9 100644
--- a/webgui/globals.inc
+++ b/webgui/globals.inc
@@ -464,155 +464,7 @@ function get_userlist() {
// ========== DATABASE FUNCTIONS ==============================================
-function db_exec_insert($table, $params) {
- // $params must have keys corresponding to table fields prefixed with ':'
- // e.g. $param[':field']
- global $pdo;
- global $g_error;
- $keys = array_keys($params);
- $fields = join(', ', array_map(function($s) { return ltrim($s, ':'); }, $keys));
- $pnames = join(', ', $keys);
- $sql = "INSERT INTO $table ($fields) VALUES ($pnames)";
-// $sth = $pdo->prepare("INSERT INTO $table ($fields) VALUES ($pnames)");
- $sth = $pdo->prepare($sql);
- try {
- $sth->execute($params);
- } catch (PDOexception $e) {
- $g_error->Add('SQL-Error: '. $e->getMessage());
- $g_error->Add($sql);
- $g_error->Add(print_r($params, true));
- return false;
- }
- return $pdo->LastInsertId();
-}
-
-function db_exec_update($table, $params, $pk) {
- // primary key can be a single field name or multiple fields: $pk is an array
- global $pdo;
- global $g_error;
- // remove primary key fields from list of fields to update
- if (is_array($pk)) {
- if (count($pk) == 1) {
- $pk = $pk[0];
- $fields = $params;
- unset($fields[':'.$pk]);
- $where = "$pk=:$pk";
- } else {
- $pkparams = array_map(fn($value) => ':' . $value, $pk);
- $fields = array_diff_key($params, array_flip($pkparams));
- $where = join(' AND ', array_map(fn($s) => "$s=:$s", $pk));
- }
- } else {
- $fields = $params;
- unset($fields[':'.$pk]);
- $where = "$pk=:$pk";
- }
- $fieldlist = join(', ', array_map(fn($s) => ltrim($s, ':') . '=' . $s, array_keys($fields)));
- $sql = "UPDATE $table SET $fieldlist WHERE $where";
- $sth = $pdo->prepare($sql);
- try {
- $sth->execute($params);
- } catch (PDOexception $e) {
- $g_error->Add('SQL-Error: '. $e->getMessage());
- $g_error->Add($sql);
- $g_error->Add(print_r($params, true));
- return false;
- }
- return true;
-}
-
-function db_exec_delete($table, $condition, $params) {
- // WIP untested!
- // condition contains the where part of the sql statement
- // params are values for placeholders in condition
- // returns the number of deleted records
- global $pdo;
- global $g_error;
- // convert params to array if single value is given
- if (!is_array($params)) {
- $params = [$params];
- }
- $sql = "DELETE FROM $table";
- if (!empty($condition)) {
- $sql .= ' WHERE ' . $condition;
- }
- $sth = $pdo->prepare($sql);
- try {
- $sth->execute($params);
- } catch (PDOexception $e) {
- $g_error->Add('SQL-Error: '. $e->getMessage());
- $g_error->Add($sql);
- $g_error->Add(print_r($params, true));
- return -1;
- }
- return $sth->rowCount();
-}
-
-
-function get_enum($enum) {
- // translate and beautify enums
- $lookup = array(
- 'NULL' => _('n/a'),
- 'active' => _('Active'),
- 'bad' => _('Bad'),
- 'box' => _('Box'),
- 'cable' => _('Cable'),
- 'cat' => _('Catamaran'),
- 'completed' => _('Completed'),
- 'closed' => _('Closed'),
- 'company' => _('Company'),
- 'day' => _('Day'),
- 'defect' => _('Defect'),
- 'deleted' => _('Deleted'),
- 'done' => _('Done'),
- 'drawing' => _('Drawing'),
- 'equipment' => _('Equipment'),
- 'estimated' => _('Estimated'),
- 'excellent' => _('Excellent'),
- 'fair' => _('Fair'),
- 'finished' => _('Finished'),
- 'fixed' => _('Fixed'),
- 'fuse' => _('Fuse'),
- 'generic' => _('Generic'),
- 'good' => _('Good'),
- 'high' => _('High'),
- 'historic' => _('Historic'),
- 'invoice' => _('Invoice'),
- 'locked' => _('Locked'),
- 'low' => _('Low'),
- 'manual' => _('Manual'),
- 'medium' => _('Medium'),
- 'missed' => _('Missed'),
- 'mono' => _('Monohull'),
- 'month' => _('Month'),
- 'new' => _('New'),
- 'none' => _('None'),
- 'normal' => _('Normal'),
- 'ongoing' => _('Ongoing'),
- 'open' => _('Open'),
- 'ordered' => _('Ordered'),
- 'paused' => _('Paused'),
- 'pending' => _('Pending'),
- 'picture' => _('Picture'),
- 'plan' => _('Planned'),
- 'precise' => _('Precise'),
- 'project' => _('Project'),
- 'quarter' => _('Quarter'),
- 'removed' => _('Removed'),
- 'repairable' => _('Repairable'),
- 'rough' => _('Rough'),
- 'skipped' => _('Skipped'),
- 'storage' => _('Storage'),
- 'task' => _('Task'),
- 'tri' => _('Trimaran'),
- 'unknown' => _('Unknown'),
- 'user' => _('User'),
- 'vessel' => _('Vessel'),
- 'waiting' => _('Waiting'),
- 'week' => _('Week'),
- );
- return $lookup[$enum] ?? $enum;
-}
+// TODO transfer to lib/db.inc
function db_load_enum($table, $column, $lookup=false, $as_dict=false, $check_null=false) {
// returns array of enum-values as defined in database
@@ -840,247 +692,6 @@ function float_to_sql($var) {
}
}
-// ========== FORM FUNCTIONS ==================================================
-
-function form_get_action() {
- if (!isset($_POST['submit'])) {
- if (isset($_GET['f'])) {
- $submit = $_GET['f'];
- // strip parameters
-/* $pos = strpos($submit, '?');
- if ($pos > 2) {
- $submit = substr($submit, 0, $pos);
- } */
- } else {
- $submit = NULL;
- }
- } else {
- $submit = $_POST['submit'];
- }
- if (is_array($submit)) {
- $submit = key($submit);
- }
- return strtolower($submit);
-}
-
-function form_create_numeric($fieldname, $label, $min=NULL, $max=NULL, $step=NULL, $value=NULL) {
- // TODO WIP
- // step = any float
- // step = 0.01 float
- // step = 1 integer
- echo '
', "\n";
- echo ' \n";
- echo "
\n";
-}
-
-function form_create_text($fieldname, $label, $maxlen=NULL, $value=NULL) {
- // create generic text entry with assigned label
- // TODO required, errortext
- echo '
', "\n";
- echo '', $label, " \n";
- echo ' \n";
- echo "
\n";
-}
-
-function form_create_textarea($fieldname, $label, $rows=3, $maxlen=NULL, $value=NULL) {
- echo '
', "\n";
- echo '', $label, " \n";
- echo '\n";
- echo "
\n";
-}
-
-function form_create_color($fieldname, $label, $value=NULL) {
- // value has to be 6char hex
- echo '
', "\n";
- echo '', $label, " \n";
- echo ' \n";
- echo "
\n";
-}
-
-function form_create_select($fieldname, $label, $optlist, $selval=NULL, $multiple=FALSE) {
- echo '
', "\n";
- echo '', $label, " \n";
- echo '', "\n";
- foreach ($optlist as $k => $v) {
- echo '', $v, " \n";
- }
- echo " \n";
- echo "
\n";
-}
-
-function form_create_option($fieldname, $label) {
- // TBD
-}
-
-function form_create_check($fieldname, $label, $checked) {
- // create single checkbox with assigned label
- echo '
', "\n";
- echo ' \n";
- echo '', $label, " \n";
- echo "
\n";
-}
-
-function form_create_checks($fieldname, $label, $optlist, $selected = []) {
- // create multiple combined checkboxes with title
- echo '
', "\n";
- echo '', $label, " \n";
- echo '';
- foreach ($optlist as $k => $v) {
- echo '
', "\n";
- $checked = in_array($k, $selected, true) ? ' checked' : '';
- echo '';
- echo ' ';
- echo $v;
- echo ' ';
- echo "
\n";
- }
- echo "
\n";
- echo " \n";
-}
-
-function form_add_button($script, $id=NULL, $idname='id') {
- echo '
\n";
-}
-
-function form_view_buttons($script, $id, $backlink=NULL) {
- echo '
\n";
-}
-
-function form_new_buttons($script) {
- echo '
\n";
-}
-
-function form_edit_buttons($script, $id) {
- echo '
\n";
-}
-
-function form_delete_buttons($script, $id, $token) {
- echo '
', "\n";
- echo '
\n";
- echo "
\n";
-}
-
-function form_tag_assignment($script, $id, $tags) {
- echo '
';
- echo '', _('Tags'), " \n";
- echo '', $tags, ' ';
- echo " \n
";
- echo '', _('Tag assignment'), " \n";
- echo ' \n";
- echo " ";
-}
-
-function filter_create_text($fieldname, $label, $value, $size=NULL, $maxlength=NULL) {
- echo '
', "\n";
- echo '', $label,' ', "\n";
- echo ' ', "\n";
- echo "
\n";
-}
-
-function filter_create_select($fieldname, $label, $optlist, $selval=NULL, $multiple=FALSE) {
- // - Wenn multiple gesetzt ist, muß selval ein array sein
- // ansonsten ein einfacher String
- /* if ($multiple) {
- if (!is_array($selval)) {
- }
- } */
- echo '
', "\n";
- echo '', $label,' ', "\n";
- echo '\n";
- foreach ($optlist as $k => $v) {
- echo '', $v, ' ', "\n";
- }
- echo " \n";
- echo "
\n";
-}
-
-function filter_create_checks($fieldname, $label, $optlist, $selected = []) {
- // TODO WIP
- echo '
', "\n";
- echo '', $label, " \n";
- echo '', "\n";
- foreach ($optlist as $k => $v) {
- echo '
', "\n";
- $checked = in_array($k, $selected, true) ? ' checked' : '';
- echo '', "\n";
- echo ' \n";
- echo $v, "\n";
- echo " \n";
- echo "
\n";
- }
- echo "
\n";
- echo " \n";
-}
-
// ========== FORMAT FUNCTIONS ================================================
function format_float($val, $decimals = 2, $suffix = '') {
@@ -1131,6 +742,9 @@ function format_datetime($datetime, $seconds=false) {
}
function format_color($color) {
+ if (empty($color)) {
+ return '';
+ }
$colstr = '
_('n/a'),
+ 'active' => _('Active'),
+ 'bad' => _('Bad'),
+ 'box' => _('Box'),
+ 'cable' => _('Cable'),
+ 'cat' => _('Catamaran'),
+ 'completed' => _('Completed'),
+ 'closed' => _('Closed'),
+ 'company' => _('Company'),
+ 'day' => _('Day'),
+ 'defect' => _('Defect'),
+ 'deleted' => _('Deleted'),
+ 'done' => _('Done'),
+ 'drawing' => _('Drawing'),
+ 'equipment' => _('Equipment'),
+ 'estimated' => _('Estimated'),
+ 'excellent' => _('Excellent'),
+ 'fair' => _('Fair'),
+ 'finished' => _('Finished'),
+ 'fixed' => _('Fixed'),
+ 'fuse' => _('Fuse'),
+ 'generic' => _('Generic'),
+ 'good' => _('Good'),
+ 'high' => _('High'),
+ 'historic' => _('Historic'),
+ 'invoice' => _('Invoice'),
+ 'locked' => _('Locked'),
+ 'low' => _('Low'),
+ 'manual' => _('Manual'),
+ 'medium' => _('Medium'),
+ 'missed' => _('Missed'),
+ 'mono' => _('Monohull'),
+ 'month' => _('Month'),
+ 'new' => _('New'),
+ 'none' => _('None'),
+ 'normal' => _('Normal'),
+ 'ongoing' => _('Ongoing'),
+ 'open' => _('Open'),
+ 'ordered' => _('Ordered'),
+ 'paused' => _('Paused'),
+ 'pending' => _('Pending'),
+ 'picture' => _('Picture'),
+ 'plan' => _('Planned'),
+ 'precise' => _('Precise'),
+ 'project' => _('Project'),
+ 'quarter' => _('Quarter'),
+ 'removed' => _('Removed'),
+ 'repairable' => _('Repairable'),
+ 'rough' => _('Rough'),
+ 'skipped' => _('Skipped'),
+ 'storage' => _('Storage'),
+ 'task' => _('Task'),
+ 'tri' => _('Trimaran'),
+ 'unknown' => _('Unknown'),
+ 'user' => _('User'),
+ 'vessel' => _('Vessel'),
+ 'waiting' => _('Waiting'),
+ 'week' => _('Week'),
+ );
+ return $lookup[$enum] ?? $enum;
+}
+
function get_color_brightness($color, $default=0.5) {
// returns a value between 0 and 1
// color is a 6 char hex string
diff --git a/webgui/index.php b/webgui/index.php
index 8deb13d..7c614ab 100644
--- a/webgui/index.php
+++ b/webgui/index.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
require 'lib/svg.inc';
$pagetitle = _('Start');
diff --git a/webgui/inventory.php b/webgui/inventory.php
index ba933e9..bc42442 100644
--- a/webgui/inventory.php
+++ b/webgui/inventory.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
$pagetitle=_('Inventory');
diff --git a/webgui/lib/db.inc b/webgui/lib/db.inc
index 2c28695..8d09912 100644
--- a/webgui/lib/db.inc
+++ b/webgui/lib/db.inc
@@ -10,6 +10,90 @@
// ========== GENERIC FUNCTIONS ===============================================
+function db_exec_insert($table, $params) {
+ // $params must have keys corresponding to table fields prefixed with ':'
+ // e.g. $param[':field']
+ global $pdo;
+ global $g_error;
+ $keys = array_keys($params);
+ $fields = join(', ', array_map(function($s) { return ltrim($s, ':'); }, $keys));
+ $pnames = join(', ', $keys);
+ $sql = "INSERT INTO $table ($fields) VALUES ($pnames)";
+// $sth = $pdo->prepare("INSERT INTO $table ($fields) VALUES ($pnames)");
+ $sth = $pdo->prepare($sql);
+ try {
+ $sth->execute($params);
+ } catch (PDOexception $e) {
+ $g_error->Add('SQL-Error: '. $e->getMessage());
+ $g_error->Add($sql);
+ $g_error->Add(print_r($params, true));
+ return false;
+ }
+ return $pdo->LastInsertId();
+}
+
+function db_exec_update($table, $params, $pk) {
+ // primary key can be a single field name or multiple fields: $pk is an array
+ global $pdo;
+ global $g_error;
+ // remove primary key fields from list of fields to update
+ if (is_array($pk)) {
+ if (count($pk) == 1) {
+ $pk = $pk[0];
+ $fields = $params;
+ unset($fields[':'.$pk]);
+ $where = "$pk=:$pk";
+ } else {
+ $pkparams = array_map(fn($value) => ':' . $value, $pk);
+ $fields = array_diff_key($params, array_flip($pkparams));
+ $where = join(' AND ', array_map(fn($s) => "$s=:$s", $pk));
+ }
+ } else {
+ $fields = $params;
+ unset($fields[':'.$pk]);
+ $where = "$pk=:$pk";
+ }
+ $fieldlist = join(', ', array_map(fn($s) => ltrim($s, ':') . '=' . $s, array_keys($fields)));
+ $sql = "UPDATE $table SET $fieldlist WHERE $where";
+ $sth = $pdo->prepare($sql);
+ try {
+ $sth->execute($params);
+ } catch (PDOexception $e) {
+ $g_error->Add('SQL-Error: '. $e->getMessage());
+ $g_error->Add($sql);
+ $g_error->Add(print_r($params, true));
+ return false;
+ }
+ return true;
+}
+
+function db_exec_delete($table, $condition, $params) {
+ // WIP untested!
+ // condition contains the where part of the sql statement
+ // params are values for placeholders in condition
+ // returns the number of deleted records
+ global $pdo;
+ global $g_error;
+ // convert params to array if single value is given
+ if (!is_array($params)) {
+ $params = [$params];
+ }
+ $sql = "DELETE FROM $table";
+ if (!empty($condition)) {
+ $sql .= ' WHERE ' . $condition;
+ }
+ $sth = $pdo->prepare($sql);
+ try {
+ $sth->execute($params);
+ } catch (PDOexception $e) {
+ $g_error->Add('SQL-Error: '. $e->getMessage());
+ $g_error->Add($sql);
+ $g_error->Add(print_r($params, true));
+ return -1;
+ }
+ return $sth->rowCount();
+}
+
function db_get_setting($sno, $userid, $autocreate=false, $default=NULL) {
global $pdo;
global $g_error;
diff --git a/webgui/lib/form.inc b/webgui/lib/form.inc
new file mode 100644
index 0000000..9b8fbf5
--- /dev/null
+++ b/webgui/lib/form.inc
@@ -0,0 +1,256 @@
+ 2) {
+ $submit = substr($submit, 0, $pos);
+ } */
+ } else {
+ $submit = NULL;
+ }
+ } else {
+ $submit = $_POST['submit'];
+ }
+ if (is_array($submit)) {
+ $submit = key($submit);
+ }
+ return strtolower($submit);
+}
+
+function form_tag_assignment($script, $id, $tags) {
+ echo '';
+ echo '', _('Tags'), " \n";
+ echo '', $tags, ' ';
+ echo " \n";
+ echo '', _('Tag assignment'), " \n";
+ echo ' \n";
+ echo " ";
+}
+
+// ========== FORM FIELDS =====================================================
+
+function form_create_numeric($fieldname, $label, $min=NULL, $max=NULL, $step=NULL, $value=NULL) {
+ // TODO WIP
+ // step = any float
+ // step = 0.01 float
+ // step = 1 integer
+ echo '', "\n";
+ echo ' \n";
+ echo "
\n";
+}
+
+function form_create_text($fieldname, $label, $maxlen=NULL, $value=NULL) {
+ // create generic text entry with assigned label
+ // TODO required, errortext
+ echo '', "\n";
+ echo '', $label, " \n";
+ echo ' \n";
+ echo "
\n";
+}
+
+function form_create_textarea($fieldname, $label, $rows=3, $maxlen=NULL, $value=NULL) {
+ echo '', "\n";
+ echo '', $label, " \n";
+ echo '\n";
+ echo "
\n";
+}
+
+function form_create_color($fieldname, $label, $value=NULL) {
+ // value has to be 6char hex
+ echo '', "\n";
+ echo '', $label, " \n";
+ echo ' \n";
+ echo "
\n";
+}
+
+function form_create_select($fieldname, $label, $optlist, $selval=NULL, $multiple=FALSE) {
+ echo '', "\n";
+ echo '', $label, " \n";
+ echo '', "\n";
+ foreach ($optlist as $k => $v) {
+ echo '', $v, " \n";
+ }
+ echo " \n";
+ echo "
\n";
+}
+
+function form_create_option($fieldname, $label) {
+ // TBD
+}
+
+function form_create_check($fieldname, $label, $checked) {
+ // create single checkbox with assigned label
+ echo '', "\n";
+ echo ' \n";
+ echo '', $label, " \n";
+ echo "
\n";
+}
+
+function form_create_checks($fieldname, $label, $optlist, $selected = []) {
+ // create multiple combined checkboxes with title
+ echo '', "\n";
+ echo '', $label, " \n";
+ echo '';
+ foreach ($optlist as $k => $v) {
+ echo '
', "\n";
+ $checked = in_array($k, $selected, true) ? ' checked' : '';
+ echo '';
+ echo ' ';
+ echo $v;
+ echo ' ';
+ echo "
\n";
+ }
+ echo "
\n";
+ echo " \n";
+}
+
+// ========== FORM BUTTONS ====================================================
+
+function form_add_button($script, $id=NULL, $idname='id') {
+ echo '\n";
+}
+
+function form_view_buttons($script, $id, $backlink=NULL) {
+ echo '\n";
+}
+
+function form_new_buttons($script) {
+ echo '\n";
+}
+
+function form_edit_buttons($script, $id) {
+ echo '\n";
+}
+
+function form_delete_buttons($script, $id, $token) {
+ echo '', "\n";
+ echo '
\n";
+ echo "
\n";
+}
+
+// ========== FILTER FIELDS ===================================================
+
+function filter_create_text($fieldname, $label, $value, $size=NULL, $maxlength=NULL) {
+ echo '', "\n";
+ echo '', $label,' ', "\n";
+ echo ' ', "\n";
+ echo "
\n";
+}
+
+function filter_create_select($fieldname, $label, $optlist, $selval=NULL, $multiple=FALSE) {
+ // - Wenn multiple gesetzt ist, muß selval ein array sein
+ // ansonsten ein einfacher String
+ /* if ($multiple) {
+ if (!is_array($selval)) {
+ }
+ } */
+ echo '', "\n";
+ echo '', $label,' ', "\n";
+ echo '\n";
+ foreach ($optlist as $k => $v) {
+ echo '', $v, ' ', "\n";
+ }
+ echo " \n";
+ echo "
\n";
+}
+
+function filter_create_checks($fieldname, $label, $optlist, $selected = []) {
+ // TODO WIP
+ echo '', "\n";
+ echo '', $label, " \n";
+ echo '', "\n";
+ foreach ($optlist as $k => $v) {
+ echo '
', "\n";
+ $checked = in_array($k, $selected, true) ? ' checked' : '';
+ echo '', "\n";
+ echo ' \n";
+ echo $v, "\n";
+ echo " \n";
+ echo "
\n";
+ }
+ echo "
\n";
+ echo " \n";
+}
diff --git a/webgui/maintenance.php b/webgui/maintenance.php
index 1531e93..4bb11f8 100644
--- a/webgui/maintenance.php
+++ b/webgui/maintenance.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
$pagetitle = _('Maintenance');
diff --git a/webgui/manual.php b/webgui/manual.php
index 403625c..3b813be 100644
--- a/webgui/manual.php
+++ b/webgui/manual.php
@@ -16,7 +16,7 @@ require 'header.php';
-Hinweis: Es handelt sich hier um eine Vorschau (Version =$g_version?>)!
+Hinweis: Es handelt sich hier um eine frühe Version (v=$g_version?>)!
Einige Funktionen sind noch nicht oder nicht vollständig implementiert.
Rückmeldungen sind immer willkommen!
diff --git a/webgui/measurement.php b/webgui/measurement.php
index 2b20015..115c306 100644
--- a/webgui/measurement.php
+++ b/webgui/measurement.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
// TODO move to somewhere else
function format_vals($n, $v1, $v2, $v3) {
diff --git a/webgui/note.php b/webgui/note.php
index 3a493b3..cf1c5a7 100644
--- a/webgui/note.php
+++ b/webgui/note.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
$pagetitle = _('Note');
diff --git a/webgui/projects.php b/webgui/projects.php
index 1df4a4d..567f39f 100644
--- a/webgui/projects.php
+++ b/webgui/projects.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
$pagetitle = _('Projects');
diff --git a/webgui/provisions.php b/webgui/provisions.php
index 9f186e6..690efde 100644
--- a/webgui/provisions.php
+++ b/webgui/provisions.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
$pagetitle=_('Provisions');
diff --git a/webgui/search.php b/webgui/search.php
index 3e6e638..1c0fbe9 100644
--- a/webgui/search.php
+++ b/webgui/search.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
$pagetitle = _('Search');
diff --git a/webgui/settings.php b/webgui/settings.php
index 7dd710c..626e41a 100644
--- a/webgui/settings.php
+++ b/webgui/settings.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
$pagetitle = _('Settings');
diff --git a/webgui/storage.php b/webgui/storage.php
index 95c4e33..70e2d18 100644
--- a/webgui/storage.php
+++ b/webgui/storage.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
$pagetitle = _('Storage');
@@ -150,8 +151,8 @@ foreach ($res as $row) {
echo "\n";
}
// Table summary
-$numrows = count($res);
-table_rec_summary($i, $numrows, $numrows, 5);
+// $numrows = count($res);
+// table_rec_summary($i, $numrows, $numrows, 5);
echo "\n";
form_add_button($g_scriptname);
@@ -191,8 +192,8 @@ foreach ($res as $row) {
echo "\n";
}
// Table summary
-$numrows = count($res);
-table_rec_summary($i, $numrows, $numrows, 5);
+// $numrows = count($res);
+// table_rec_summary($i, $numrows, $numrows, 5);
echo "\n";
form_add_button('box.php');
diff --git a/webgui/tag.php b/webgui/tag.php
index df945ed..f58c839 100644
--- a/webgui/tag.php
+++ b/webgui/tag.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
$pagetitle = _('Tags');
@@ -141,7 +142,8 @@ foreach ($res as $row) {
echo "\n";
}
// Table summary
-table_rec_summary($i0, $i, $numrows, 6);
+$numrows = count($res);
+table_rec_summary(1, $i, $numrows, 6);
echo "\n";
form_add_button($g_scriptname);
diff --git a/webgui/task.php b/webgui/task.php
index 8ad1054..8d9508f 100644
--- a/webgui/task.php
+++ b/webgui/task.php
@@ -9,6 +9,7 @@
require 'globals.inc';
require 'lib/db.inc';
require 'lib/gpc.inc';
+require 'lib/form.inc';
$pagetitle = _('Task');