Webgui: fix and improve cables and fuses

This commit is contained in:
2026-08-29 14:27:16 +02:00
parent ac4b994398
commit 125a7bba56
4 changed files with 37 additions and 16 deletions
+12 -8
View File
@@ -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 "<td>", $row['length'], "m</td>\n";
echo "<td>", $row['xsection'], "mm²</td>\n";
echo "<td>", format_color($row['color']), "</td>\n";
echo "<td>", $row['condition'], "</td>\n";
echo "<td>", get_enum($row['cablecond']), "</td>\n";
echo "<td>";
echo '<a title="', _('Edit'), '" href="', $g_scriptname, '?f=edit&id=', $row['cableid'], '"><i class="bi-pencil"></i></a>', "\n";
echo "</td>\n";
echo "</tr>\n";
}
// Table summary
table_rec_summary($i0, $i, $numrows, 6);
table_rec_summary(1, $i, $i, 9);
echo "</table>\n";
form_add_button($g_scriptname);
@@ -177,8 +179,8 @@ echo '<h2>', _('Add Cable'), "</h2>\n";
form_create_select('cabletype', _('Type'), $g_opt_none + $opt_cabletype);
?>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Conductors')?></label>
<input type="text" class="form-control" id="conductors" name="conductors">
<label for="note" class="form-label"><?=_('Number of conductors')?></label>
<input type="number" class="form-control" id="conductors" name="conductors">
</div>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Cross section, mm²')?></label>
@@ -191,7 +193,7 @@ echo "</form>\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 '<h2>', _('View cable'), "</h2>\n";
echo '<table class="table">', "\n";
echo '<tr><th style="width:20%">', _('Cable'),"</th><td>", $cable->cablename, "</td></tr>\n";
echo '<tr><th>', _('Type'),"</th><td>", $opt_cabletype[$cable->cabletype], "</td></tr>\n";
echo '<tr><th>', _('Techname'),"</th><td>", $opt_techname[$cable->techname], "</td></tr>\n";
echo '<tr><th>', _('Length'),"</th><td>", format_float($cable->length, 1, 'm'), "</td></tr>\n";
echo '<tr><th>', _('Conductors'),"</th><td>", $cable->conductors, "</td></tr>\n";
echo '<tr><th>', _('Diameter'),"</th><td>", format_float($cable->diameter, 1, 'mm'), "</td></tr>\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 '<h2>', _('Edit cable'), "</h2>\n";
</div>
<?php
form_create_select('cabletype', _('Type'), $g_opt_none + $opt_cabletype, $cable->cabletype);
form_create_select('techname', _('Techname'), $g_opt_none + $opt_techname, $cable->techname);
?>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Length, m')?></label>
<input type="text" class="form-control" id="length" name="length" value="<?=format_float($cable->length, 1);?>">
</div>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Conductors')?></label>
<input type="text" class="form-control" id="conductors" name="conductors" value="<?=$cable->conductors;?>">
<label for="note" class="form-label"><?=_('Number of conductors')?></label>
<input type="number" class="form-control" id="conductors" name="conductors" value="<?=$cable->conductors;?>">
</div>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Diameter, mm')?></label>