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
+21 -6
View File
@@ -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 '<h2>', _('View fuse'), "</h2>\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 '<h2>', _('Edit fuse'), "</h2>\n";
<form method="post" action="<?=$g_scriptname?>">
<input type="hidden" name="id" value="<?=$id?>">
<div class="mb-3">
<label for="mname" class="form-label"><?=pgettext('number', 'Number')?></label>
<label for="fnumber" class="form-label"><?=_('Fuse number')?></label>
<input type="text" class="form-control" id="fnumber" name="fnumber" value="<?=$fuse->fnumber ?>">
</div>
<div class="mb-3">
<label for="note" class="form-label"><?=_('Description')?></label>
<input type="text" class="form-control" id="description" name="description" value="<?=h($fuse->description)?>">
</div>
<div class="mb-3">
<label for="current" class="form-label"><?=_('Current')?></label>
<input type="text" class="form-control" id="current" name="current" value="<?=format_float($fuse->current) ?>">
</div>
<?php
form_create_select('location', _('Location'), $g_opt_none + $opt_location, $fuse->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);
?>
<div class="mb-3">
<label for="remarks" class="form-label"><?=_('Remarks')?></label>
<textarea class="form-control" id="remarks" name="remarks" rows="3"><?=h($fuse->remarks, br:true)?></textarea>
</div>
<?php
form_edit_buttons($g_scriptname, $id);