Ongoing webgui work

This commit is contained in:
2025-04-01 14:49:03 +02:00
parent 0c09ce2916
commit c293ca1caa
20 changed files with 572 additions and 166 deletions
+64 -3
View File
@@ -38,7 +38,7 @@ switch ($submit = form_get_action()) {
case 'update':
$p[':tagid'] = $id;
$p[':tagname'] = gpc_get_string($_POST, 'tagname');
$p[':color'] = gpc_get_string($_POST, 'color');
$p[':color'] = gpc_get_color($_POST, 'color');
$p[':description'] = gpc_get_string($_POST, 'description');
db_exec_update('tag', $p, 'tagid');
$action = ACT_VIEW;
@@ -77,6 +77,8 @@ $flt = db_get_filter($user->id, 210);
echo "<h1>$pagetitle</h1>\n";
// db_save_taglist('inv', 1, 'apple, banana , , , orange, ddd');
// Filter
?>
<form method="post" action="<?=$g_scriptname?>">
@@ -85,7 +87,7 @@ echo "<h1>$pagetitle</h1>\n";
<div class="card-body">
<label for="flt_txt">Text</label>
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt?>">
<input type="text" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt ?? ''?>">
<button name="submit[filter]" class="btn btn-sm btn-primary" title="<?=_('Apply')?>"><?=_('Go')?></button>
</div>
</div>
@@ -110,7 +112,7 @@ foreach ($res as $row) {
echo "<tr>\n";
echo "<td>", $row['tagname'], "</td>\n";
echo "<td>", $row['description'], "</td>\n";
echo "<td>", $row['color'], "</td>\n";
echo "<td>", format_color($row['color']), "</td>\n";
echo "<td>";
// Action buttons
form_action_buttons($g_scriptname, $row['tagid']);
@@ -147,6 +149,50 @@ echo "</form>\n";
elseif ($action == ACT_VIEW):
// ========== VARIANT: view single record =====================================
$sql = "SELECT tagname, description, color "
. "FROM tag "
. "WHERE tagid=?";
$sth = $pdo->prepare($sql);
$sth->execute([$id]);
$tag = $sth->fetch(PDO::FETCH_OBJ);
echo '<h2>', _('View Tag'), "</h2>\n";
echo '<table class="table">', "\n";
echo '<tr><th style="width:20%">', _('Tag'),"</th><td>", $tag->tagname, "</td></tr>\n";
echo '<tr><th>', _('Color'),"</th><td>", format_color($tag->color), "</td></tr>\n";
echo '<tr><th>', _('Description'),"</th><td>", $tag->description, "</td></tr>\n";
echo "</table>\n";
form_view_buttons($g_scriptname, $id);
echo '<h3>', _('Tag usage'), "</h3>\n";
$sql = "SELECT objid, objtype FROM tagref WHERE tagid=?";
$sth = $pdo->prepare($sql);
$sth->execute([$id]);
$link = array(
'equip' => 'equipment.php',
'inv' => 'inventory.php',
'prov' => 'provisions.php',
'doc' => 'documents.php',
'proj' => 'projects.php',
'task' => 'task.php',
'maint' => 'maintenance.php'
);
echo '<p>';
if ($sth->rowCount() > 0) {
foreach ($sth->fetchAll() as $row) {
echo '<a href="', $link[$row['objtype']], '?f=view&id=', $row['objid'], '">', $row['objid'], '/', $row['objtype'], "</a>\n";
}
} else {
echo _('Tag is not used anywhere');
}
echo "</p>\n";
echo '<h3>', _('Related tags'), "</h3>\n";
echo '<p>', _('Not yet implemented'), "</p>\n";
elseif ($action == ACT_EDIT):
// ========== VARIANT: edit single record =====================================
@@ -181,6 +227,21 @@ echo "</form>\n";
elseif ($action == ACT_DELETE):
// ========== VARIANT: delete record ==========================================
echo '<h2>', _('Delete tag'), "</h2>\n";
$sql = "SELECT objid, objtype FROM tagref WHERE tagid=?";
$sth = $pdo->prepare($sql);
$sth->execute([$id]);
if ($sth->rowCount() > 0) {
foreach ($sth->fetchAll() as $row) {
echo '<a href="', $link[$row['objtype']], '?f=view&id=', $row['objid'], '">', $row['objid'], '/', $row['objtype'], "</a>\n";
}
} else {
echo _('Tag is not used anywhere');
$_SESSION['token'] = bin2hex(random_bytes(8));
form_delete_buttons($g_scriptname, $id, $_SESSION['token']);
}
else:
// ========== ERROR UNKNOWN VARIANT ===========================================