Webgui: filter and pagination working
This commit is contained in:
+61
-21
@@ -80,7 +80,7 @@ if ($action == ACT_DEFAULT):
|
||||
// ========== VARIANT: default behavior =======================================
|
||||
|
||||
// load filter from db
|
||||
$flt = db_get_filter($user->id, 210);
|
||||
$flt = db_get_filter($user->id, 210, ['txt']);
|
||||
|
||||
echo "<h1>$pagetitle</h1>\n";
|
||||
|
||||
@@ -91,12 +91,15 @@ echo "<h1>$pagetitle</h1>\n";
|
||||
<form method="post" action="<?=$g_scriptname?>">
|
||||
<div id="filter" class="card">
|
||||
<div class="card-header"><i class="bi bi-funnel me-2"></i>Filter</div>
|
||||
<div class="card-body">
|
||||
|
||||
<label for="flt_txt">Text</label>
|
||||
<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>
|
||||
<button name="submit[freset]" class="btn btn-sm btn-secondary float-end" title="<?=_('Reset filter to defaults')?>"><?=_('Clear')?></button>
|
||||
<div class="card-body d-flex flex-wrap gap-3">
|
||||
<div class="d-flex flex-nowrap gap-2">
|
||||
<label for="flt_txt">Text</label>
|
||||
<input type="text" class="form-control" name="flt_txt" size="15" maxlength="30" value="<?=$flt->txt ?? ''?>">
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<button name="submit[filter]" class="btn btn-sm btn-primary" title="<?=_('Apply')?>"><?=_('Go')?></button>
|
||||
<button name="submit[freset]" class="btn btn-sm btn-secondary float-end" title="<?=_('Reset filter to defaults')?>"><?=_('Clear')?></button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
@@ -110,20 +113,29 @@ $res = $sth->fetchAll();
|
||||
echo '<table class="table table-striped">', "\n";
|
||||
echo "<thead>\n";
|
||||
echo "<tr>\n";
|
||||
echo '<th>#</th>';
|
||||
echo '<th>', _('Tag'), "</th>";
|
||||
echo '<th>', _('Description'), "</th>";
|
||||
echo '<th>', _('Color'), "</th>";
|
||||
echo "<th></th>";
|
||||
echo "</tr>\n";
|
||||
echo "</thead>\n";
|
||||
$i = 0;
|
||||
foreach ($res as $row) {
|
||||
$i++; // record number
|
||||
echo "<tr>\n";
|
||||
echo '<td>', $i;
|
||||
echo '<a class="text-nowrap" title="', _('View'), '" href="', $g_scriptname, '?f=view&id=', $row['tagid'], '"><i class="bi bi-eye ms-2"></i></a>', "\n";
|
||||
echo "</td>\n";
|
||||
echo "<td>", $row['tagname'], "</td>\n";
|
||||
echo "<td>", $row['description'], "</td>\n";
|
||||
echo "<td>", format_color($row['color']), "</td>\n";
|
||||
echo "<td>";
|
||||
// Action buttons
|
||||
form_action_buttons($g_scriptname, $row['tagid']);
|
||||
// Edit current record button
|
||||
echo "<td>";
|
||||
echo '<a title="', _('Edit'), '" href="', $g_scriptname, '?f=edit&id=', $row['tagid'], '"><i class="bi-pencil"></i></a>', "\n";
|
||||
echo "</td>\n";
|
||||
|
||||
echo "</td>\n";
|
||||
echo "</tr>\n";
|
||||
}
|
||||
@@ -179,19 +191,47 @@ $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";
|
||||
$res = $sth->fetchAll();
|
||||
foreach ($res as $row) {
|
||||
// select object name or description depending on objecttype
|
||||
// TODO function db_get_tag_target($objtype, $objid);
|
||||
/*switch ($row['objtype']) {
|
||||
case 'equip':
|
||||
$sql = "SELECT ename FROM equipment WHERE eid=?";
|
||||
$target = "equipment.php";
|
||||
break;
|
||||
case 'inv':
|
||||
$sql = "SELECT invname FROM inventory WHERE invid=?";
|
||||
$target = "inventory.php";
|
||||
break;
|
||||
case 'prov':
|
||||
$sql = "SELECT provname FROM provisions WHERE provvid=?";
|
||||
$target = "provisions.php";
|
||||
break;
|
||||
case 'doc':
|
||||
$sql = "SELECT title FROM document WHERE docid=?";
|
||||
$target = "documents.php";
|
||||
break;
|
||||
case 'proj':
|
||||
$sql = "SELECT projname FROM project WHERE projid=?";
|
||||
$target = "projects.php";
|
||||
break;
|
||||
case 'task':
|
||||
$sql = "SELECT taskname FROM task WHERE taskid=?";
|
||||
$target = "task.php";
|
||||
break;
|
||||
case 'maint':
|
||||
$sql = "SELECT activities FROM maintenance WHERE maintid=?";
|
||||
$target = 'maintenance.php';
|
||||
break;
|
||||
}
|
||||
$sth = $pdo->prepare($sql);
|
||||
$sth->execute([$row['objid']]);
|
||||
$desc = $sth->fetchColumn(); */
|
||||
[$target, $desc] = db_get_tag_target($row['objtype'], $row['objid']);
|
||||
echo '<a href="', $target, '?f=view&id=', $row['objid'], '">', $desc, ' (', $row['objid'], '/', $row['objtype'], ")</a>\n";
|
||||
}
|
||||
} else {
|
||||
echo _('Tag is not used anywhere');
|
||||
@@ -242,7 +282,7 @@ $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";
|
||||
echo '<a href="', [$row['objtype']], '?f=view&id=', $row['objid'], '">', $row['objid'], '/', $row['objtype'], "</a>\n";
|
||||
}
|
||||
} else {
|
||||
echo _('Tag is not used anywhere');
|
||||
|
||||
Reference in New Issue
Block a user