From 125a7bba56f2a8345ce3a2dfaaddb78fc92d92c4 Mon Sep 17 00:00:00 2001 From: Thomas Hooge Date: Sat, 29 Aug 2026 14:27:16 +0200 Subject: [PATCH] Webgui: fix and improve cables and fuses --- db/minimal.sql | 3 ++- webgui/cable.php | 20 ++++++++++++-------- webgui/fuse.php | 27 +++++++++++++++++++++------ webgui/globals.inc | 3 ++- 4 files changed, 37 insertions(+), 16 deletions(-) diff --git a/db/minimal.sql b/db/minimal.sql index d6ab09f..13832f2 100644 --- a/db/minimal.sql +++ b/db/minimal.sql @@ -67,7 +67,8 @@ INSERT INTO dropdown (ddid, ddval, ddtext) VALUES (0, 8, 'Einheiten'), (0, 9, 'Kistentypen'), (0, 10, 'Sicherungsblöcke'), -- fuse locations -(0, 11, 'Kabeltypen'); +(0, 11, 'Kabeltypen'), +(0, 12, 'Technische Kabel-Bezeichnung'); INSERT INTO dropdown (ddid, ddval, ddtext, flags) VALUES (2, 1, 'Lieferant', 'fixed'), diff --git a/webgui/cable.php b/webgui/cable.php index 5f88aa8..44bf457 100644 --- a/webgui/cable.php +++ b/webgui/cable.php @@ -14,6 +14,7 @@ $pagetitle = _('Cables'); $id = gpc_get_int($_REQUEST, 'id', 0); $opt_cabletype = db_get_options(11); +$opt_techname = db_get_options(12); $opt_cablecond = db_load_enum('cable', 'cablecond', true, true); // ========== ACTIONS START =================================================== @@ -52,6 +53,7 @@ switch ($submit = form_get_action()) { $p[':cableid'] = $id; $p[':cablename'] = gpc_get_string($_POST, 'cablename'); $p[':cabletype'] = gpc_get_int($_POST, 'cabletype'); + $p[':techname'] = gpc_get_int($_POST, 'techname'); $p[':length'] = gpc_get_float($_POST, 'length'); $p[':conductors'] = gpc_get_int($_POST, 'conductors'); $p[':xsection'] = gpc_get_float($_POST, 'xsection'); @@ -146,14 +148,14 @@ foreach ($res as $row) { echo "", $row['length'], "m\n"; echo "", $row['xsection'], "mm²\n"; echo "", format_color($row['color']), "\n"; - echo "", $row['condition'], "\n"; + echo "", get_enum($row['cablecond']), "\n"; echo ""; echo '', "\n"; echo "\n"; echo "\n"; } // Table summary -table_rec_summary($i0, $i, $numrows, 6); +table_rec_summary(1, $i, $i, 9); echo "\n"; form_add_button($g_scriptname); @@ -177,8 +179,8 @@ echo '

', _('Add Cable'), "

\n"; form_create_select('cabletype', _('Type'), $g_opt_none + $opt_cabletype); ?>
- - + +
@@ -191,7 +193,7 @@ echo "\n"; elseif ($action == ACT_VIEW): // ========== VARIANT: view single record ===================================== -$sql = "SELECT cablename, cabletype, length, conductors, diameter, xsection," +$sql = "SELECT cablename, cabletype, techname, length, conductors, diameter, xsection," . " weight, color, supplier, manufacturer, cablecond, remarks " . "FROM cable " . "WHERE cableid=?"; @@ -204,6 +206,7 @@ echo '

', _('View cable'), "

\n"; echo '', "\n"; echo '\n"; echo '\n"; +echo '\n"; echo '\n"; echo '\n"; echo '\n"; @@ -219,7 +222,7 @@ form_view_buttons($g_scriptname, $id); elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== -$sql = "SELECT cablename, cabletype, length, conductors, diameter, xsection," +$sql = "SELECT cablename, cabletype, techname, length, conductors, diameter, xsection," . " weight, color, supplier, manufacturer, cablecond, remarks " . "FROM cable " . "WHERE cableid=?"; @@ -237,14 +240,15 @@ echo '

', _('Edit cable'), "

\n"; cabletype); +form_create_select('techname', _('Techname'), $g_opt_none + $opt_techname, $cable->techname); ?>
- - + +
diff --git a/webgui/fuse.php b/webgui/fuse.php index fdcf3ee..b177267 100644 --- a/webgui/fuse.php +++ b/webgui/fuse.php @@ -57,11 +57,10 @@ switch ($submit = form_get_action()) { $p[':current'] = gpc_get_float($_POST, 'current'); $p[':cableid'] = gpc_get_int($_POST, 'cableid'); $p[':eid'] = gpc_get_int($_POST, 'id'); - $p[':weight'] = min(gpc_get_float($_POST, 'weight'), 9.99); // limit max value $p[':location'] = gpc_get_int($_POST, 'location'); $p[':description'] = gpc_get_string($_POST, 'description'); $p[':remarks'] = gpc_get_string($_POST, 'remarks'); - db_exec_update('tag', $p, 'tagid'); + db_exec_update('fuse', $p, 'fuseid'); $action = ACT_VIEW; break; @@ -219,9 +218,9 @@ elseif ($action == ACT_VIEW): $sql = "SELECT fnumber, ftype, current, cableid, eid, location, description, remarks " . "FROM fuse " - . "WHERE fuseid=?"; + . "WHERE vid=? AND fuseid=?"; $sth = $pdo->prepare($sql); -$sth->execute([$id]); +$sth->execute([$user->vid, $id]); $fuse = $sth->fetch(PDO::FETCH_OBJ); echo '

', _('View fuse'), "

\n"; @@ -242,7 +241,10 @@ form_view_buttons($g_scriptname, $id); elseif ($action == ACT_EDIT): // ========== VARIANT: edit single record ===================================== -$sql = "SELECT fnumber, description " +$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 " . "FROM fuse " . "WHERE fuseid=?"; $sth = $pdo->prepare($sql); @@ -254,13 +256,26 @@ echo '

', _('Edit fuse'), "

\n";
- +
+
+ + +
+location); +form_create_select('cableid', _('Cable'), $g_opt_none + $opt_cable, $fuse->cableid); +form_create_select('eid', _('Equipment'), $g_opt_none + $opt_equipment, $fuse->eid); +?> +
+ + +
query($sql); + $sth = $pdo->prepare($sql); + $sth->execute([$vid]); foreach ($sth->fetchAll(PDO::FETCH_NUM) as $row) { $list[$row[0]] = h($row[1]); }
', _('Cable'),"", $cable->cablename, "
', _('Type'),"", $opt_cabletype[$cable->cabletype], "
', _('Techname'),"", $opt_techname[$cable->techname], "
', _('Length'),"", format_float($cable->length, 1, 'm'), "
', _('Conductors'),"", $cable->conductors, "
', _('Diameter'),"", format_float($cable->diameter, 1, 'mm'), "